Skip to content

Commit

Permalink
Don't display paths with cargo clean --dry-run without --verbose
Browse files Browse the repository at this point in the history
The paths themselves aren't particularly interesting.
  • Loading branch information
ehuss committed Sep 20, 2023
1 parent f61d42d commit c204734
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/cargo/ops/cargo_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,8 @@ impl<'cfg> CleanContext<'cfg> {
}
};

if self.dry_run {
// Concise because if in verbose mode, the path will be written in
// the loop below.
self.config
.shell()
.concise(|shell| Ok(writeln!(shell.out(), "{}", path.display())?))?;
} else {
// dry-run displays paths while walking, so don't print here.
if !self.dry_run {
self.config
.shell()
.verbose(|shell| shell.status("Removing", path.display()))?;
Expand Down Expand Up @@ -369,6 +364,10 @@ impl<'cfg> CleanContext<'cfg> {
let entry = entry?;
self.progress.on_clean()?;
if self.dry_run {
// This prints the path without the "Removing" status since I feel
// like it can be surprising or even frightening if cargo says it
// is removing something without actually removing it. And I can't
// come up with a different verb to use as the status.
self.config
.shell()
.verbose(|shell| Ok(writeln!(shell.out(), "{}", entry.path().display())?))?;
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ fn clean_dry_run() {
p.cargo("check").run();
let before = ls_r();
p.cargo("clean --dry-run")
.with_stdout("[CWD]/target")
.with_stderr(
"[SUMMARY] [..] files, [..] total\n\
[WARNING] no files deleted due to --dry-run",
Expand Down

0 comments on commit c204734

Please sign in to comment.