Skip to content

Commit 2a5ff4c

Browse files
committed
Auto merge of #11579 - kawaemon:show-progress-on-git-cli-fetch, r=weihanglo
Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled ### What does this PR try to resolve? This PR fixes #11574 . ### How should we test and review this PR? Please run `cargo` with `net.git-fetch-with-cli` option enabled. It should show `git fetch`'s progress output like below. ``` ❯ CARGO_NET_GIT_FETCH_WITH_CLI=true ./target/debug/cargo b Updating crates.io index remote: Enumerating objects: 139821, done. remote: Counting objects: 100% (2226/2226), done. remote: Compressing objects: 100% (769/769), done. receiving objects: 0% (1/139821) ```
2 parents f0b6f81 + 5bd8ef6 commit 2a5ff4c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/cargo/sources/git/utils.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Utilities for handling git repositories, mainly around
22
//! authentication/cloning.
33
4-
use crate::core::GitReference;
4+
use crate::core::{GitReference, Verbosity};
55
use crate::util::errors::CargoResult;
66
use crate::util::{human_readable_bytes, network, Config, IntoUrl, MetricsCounter, Progress};
77
use anyhow::{anyhow, Context as _};
@@ -933,6 +933,15 @@ fn fetch_with_cli(
933933
if tags {
934934
cmd.arg("--tags");
935935
}
936+
match config.shell().verbosity() {
937+
Verbosity::Normal => {}
938+
Verbosity::Verbose => {
939+
cmd.arg("--verbose");
940+
}
941+
Verbosity::Quiet => {
942+
cmd.arg("--quiet");
943+
}
944+
}
936945
cmd.arg("--force") // handle force pushes
937946
.arg("--update-head-ok") // see discussion in #2078
938947
.arg(url)
@@ -952,7 +961,7 @@ fn fetch_with_cli(
952961
config
953962
.shell()
954963
.verbose(|s| s.status("Running", &cmd.to_string()))?;
955-
cmd.exec_with_output()?;
964+
cmd.exec()?;
956965
Ok(())
957966
}
958967

tests/testsuite/git.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2749,6 +2749,8 @@ fn use_the_cli() {
27492749
let stderr = "\
27502750
[UPDATING] git repository `[..]`
27512751
[RUNNING] `git fetch [..]`
2752+
From [..]
2753+
* [new ref] -> origin/HEAD
27522754
[COMPILING] dep1 [..]
27532755
[RUNNING] `rustc [..]`
27542756
[COMPILING] foo [..]

0 commit comments

Comments
 (0)