Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/util/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,33 @@ impl<'gctx> Progress<'gctx> {
style: ProgressStyle,
gctx: &'gctx GlobalContext,
) -> Progress<'gctx> {
let progress_config = gctx.progress_config();
let progress = match progress_config.when {
ProgressWhen::Always => true,
ProgressWhen::Never => false,
ProgressWhen::Auto => Self::progress_supported(gctx),
};
if progress {
Progress::new_priv(name, style, gctx)
} else {
return Progress { gctx, state: None };
}
}

fn progress_supported(gctx: &'gctx GlobalContext) -> bool {
// report no progress when -q (for quiet) or TERM=dumb are set
// or if running on Continuous Integration service like Travis where the
// output logs get mangled.
let dumb = match gctx.get_env("TERM") {
#[allow(clippy::disallowed_methods, reason = "not a cargo env")]
let dumb = match std::env::var("TERM") {
Comment on lines +76 to +77

@weihanglo weihanglo Jul 21, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can think of "TERM" as a cargo env in disguise. Anyway, I don't think it matter and I got why you did this change first.

View changes since the review

Ok(term) => term == "dumb",
Err(_) => false,
};
let progress_config = gctx.progress_config();
match progress_config.when {
ProgressWhen::Always => return Progress::new_priv(name, style, gctx),
ProgressWhen::Never => return Progress { gctx, state: None },
ProgressWhen::Auto => {}
}
if gctx.shell().verbosity() == Verbosity::Quiet || dumb || is_ci() {
return Progress { gctx, state: None };
false
} else {
true
}
Progress::new_priv(name, style, gctx)
}

fn new_priv(name: &str, style: ProgressStyle, gctx: &'gctx GlobalContext) -> Progress<'gctx> {
Expand Down