Skip to content

Commit

Permalink
show fixes as well (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Sep 18, 2022
1 parent f4d8198 commit 2237495
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion git-repository/src/remote/connection/ref_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use git_protocol::transport::client::Transport;

use crate::remote::{connection::HandshakeWithRefs, fetch, Connection, Direction};

/// The error returned by [`Connection::list_refs_to_map()`].
/// The error returned by [`Connection::ref_map()`].
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
Expand Down
12 changes: 10 additions & 2 deletions gitoxide-core/src/repository/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ mod refs_impl {
kind: refs::Kind,
mut progress: impl git::Progress,
out: impl std::io::Write,
err: impl std::io::Write,
refs::Context { format, name, url }: refs::Context,
) -> anyhow::Result<()> {
use anyhow::Context;
Expand Down Expand Up @@ -64,7 +65,7 @@ mod refs_impl {
.await?;

match kind {
refs::Kind::Tracking { .. } => print_refmap(&repo, remote, map, out),
refs::Kind::Tracking { .. } => print_refmap(&repo, remote, map, out, err),
refs::Kind::Remote => {
match format {
OutputFormat::Human => drop(print(out, &map.remote_refs)),
Expand All @@ -84,6 +85,7 @@ mod refs_impl {
remote: git::Remote<'_>,
mut map: git::remote::fetch::RefMap,
mut out: impl std::io::Write,
mut err: impl std::io::Write,
) -> anyhow::Result<()> {
let mut last_spec_index = usize::MAX;
map.mappings.sort_by_key(|m| m.spec_index);
Expand All @@ -105,7 +107,7 @@ mod refs_impl {
};
match &mapping.local {
Some(local) => {
write!(out, " -> {} ", local)?;
write!(out, " -> {local} ")?;
match repo.try_find_reference(local)? {
Some(tracking) => {
let msg = match tracking.try_id() {
Expand All @@ -122,6 +124,12 @@ mod refs_impl {
None => writeln!(out, " (fetch only)"),
}?;
}
if !map.fixes.is_empty() {
writeln!(err, "Fixes and sanitizations")?;
for fix in &map.fixes {
writeln!(err, "\t{fix:?}")?;
}
}
Ok(())
}

Expand Down
4 changes: 3 additions & 1 deletion src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,13 @@ pub fn main() -> Result<()> {
progress,
progress_keep_open,
core::repository::remote::refs::PROGRESS_RANGE,
move |progress, out, _err| {
move |progress, out, err| {
core::repository::remote::refs(
repository(Mode::LenientWithGitInstallConfig)?,
kind,
progress,
out,
err,
core::repository::remote::refs::Context { name, url, format },
)
},
Expand All @@ -160,6 +161,7 @@ pub fn main() -> Result<()> {
kind,
progress,
std::io::stdout(),
std::io::stderr(),
core::repository::remote::refs::Context { name, url, format },
))
}
Expand Down
3 changes: 1 addition & 2 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pub mod config {

pub mod remote {
use git_repository as git;
use git_repository::bstr::BString;

#[derive(Debug, clap::Parser)]
pub struct Platform {
Expand Down Expand Up @@ -140,7 +139,7 @@ pub mod remote {
RefMap {
/// Override the built-in and configured ref-specs with one or more of the given ones.
#[clap(parse(try_from_os_str = git::env::os_str_to_bstring))]
ref_spec: Vec<BString>,
ref_spec: Vec<git_repository::bstr::BString>,
},
}
}
Expand Down

0 comments on commit 2237495

Please sign in to comment.