Skip to content

Commit

Permalink
support for handshake information in gix fetch (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 2, 2022
1 parent ce9b591 commit c47dcc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub struct Options {
pub remote: Option<String>,
/// If non-empty, override all ref-specs otherwise configured in the remote
pub ref_specs: Vec<BString>,
pub handshake_info: bool,
}

pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;
Expand All @@ -30,6 +31,7 @@ pub(crate) mod function {
format,
dry_run,
remote,
handshake_info,
ref_specs,
}: Options,
) -> anyhow::Result<()> {
Expand All @@ -47,6 +49,11 @@ pub(crate) mod function {
.with_dry_run(dry_run)
.receive(&git::interrupt::IS_INTERRUPTED)?;

if handshake_info {
writeln!(out, "Handshake Information")?;
writeln!(out, "\t{:?}", res.ref_map.handshake)?;
}

let ref_specs = remote.refspecs(git::remote::Direction::Fetch);
match res.status {
Status::NoChange => {
Expand Down
2 changes: 2 additions & 0 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ pub fn main() -> Result<()> {
#[cfg(feature = "gitoxide-core-blocking-client")]
Subcommands::Fetch(crate::plumbing::options::fetch::Platform {
dry_run,
handshake_info,
remote,
ref_spec,
}) => {
let opts = core::repository::fetch::Options {
format,
dry_run,
remote,
handshake_info,
ref_specs: ref_spec,
};
prepare_and_run(
Expand Down
6 changes: 5 additions & 1 deletion src/plumbing/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ pub mod fetch {
#[clap(long, short = 'n')]
pub dry_run: bool,

/// Output additional typically information provided by the server as part of the connection handshake.
#[clap(long, short = 'H')]
pub handshake_info: bool,

/// The name of the remote to connect to, or the url of the remote to connect to directly.
///
/// If unset, the current branch will determine the remote.
Expand All @@ -149,7 +153,7 @@ pub mod remote {
pub name: Option<String>,

/// Output additional typically information provided by the server as part of the connection handshake.
#[clap(long)]
#[clap(long, short = 'H')]
pub handshake_info: bool,

/// Subcommands
Expand Down

0 comments on commit c47dcc6

Please sign in to comment.