-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some enhancements to cargo clean
#12638
Conversation
r? @weihanglo (rustbot has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #12637) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw Ed is reviewing. I'll step back and take a rest 😁
Agreed that there isn't too much to learn. We also have a precedence for this and I'd love to see us extend that precedence further. |
e176917
to
5c46e80
Compare
☔ The latest upstream changes (presumably #12578) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to r= me when its ready
This came from rust-lang#12638 and my many small frustrations from wanting to use `-n` and not being able to. We do not have any existing `-n` flags for this to be confused with. I would wager that `-n` is such an entrenched short flag in build tools that it would not make sense for us to use it with any other flag. For a survey of where `-n` is used as a short, see https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table
This came from rust-lang#12638 and my many small frustrations from wanting to use `-n` and not being able to. We do not have any existing `-n` flags for this to be confused with. I would wager that `-n` is such an entrenched short flag in build tools that it would not make sense for us to use it with any other flag. For a survey of where `-n` is used as a short, see https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table
feat(cli): Add '-n' to dry-run This came from #12638 and my many small frustrations from wanting to use `-n` and not being able to. We do not have any existing `-n` flags for this to be confused with. I would wager that `-n` is such an entrenched short flag in build tools that it would not make sense for us to use it with any other flag. For a survey of where `-n` is used as a short, see https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table
This refactors some of the `cargo clean` code to wrap the "cleaning" operation in a `CleanContext` so that the context can be passed to other parts of cargo which can perform their own cleaning operations. There are some minor changes in the error messages to prepare for cleaning operations that aren't directly related to the build directory.
This adds a `--dry-run` option to have `cargo clean` display what it would delete without actually deleting it.
This adds a summary at the end when `cargo clean` finishes that displays how many files and bytes were removed.
And drop the `-n` short flag until we decide to commit to using it generally.
The previous status line was a little awkward in the way it combined both counts. I don't think showing the directories is particularly interesting, so they are only displayed when no files are deleted.
This makes it more consistent with other `--dry-run` commands, and makes it clearer to the user that cargo did not do anything.
The paths themselves aren't particularly interesting.
5c46e80
to
655f75d
Compare
@bors r=epage |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request. |
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
Update cargo 19 commits in b4ddf95ad9954118ac0dae835f2966394ad04c02..414d9e3a6d8096f3e276234ce220c868767a8792 2023-09-18 03:48:09 +0000 to 2023-09-22 07:03:57 +0000 - refactor(TomlManifest): fail when package_root is not a directory (rust-lang/cargo#12722) - Better suggestion for unsupported mode in build command (rust-lang/cargo#12693) - Update curl-sys to pull in curl 8.3.0 (rust-lang/cargo#12718) - chore(ci): Ignore patch version in MSRV (rust-lang/cargo#12716) - refactor: move cached crates.io SourceID to config module (rust-lang/cargo#12711) - fix: typos in registry authentication documentation (rust-lang/cargo#12714) - doc: mention unstable flag `-Z asymmetric-token` (rust-lang/cargo#12712) - fix: copy PDBs for EFI targets (rust-lang/cargo#12688) - infra: add auto-trigger rules for new labels (rust-lang/cargo#12713) - fix: use channel-specific link for registry auth error (rust-lang/cargo#12709) - Add some enhancements to `cargo clean` (rust-lang/cargo#12638) - chore: Fix typos (rust-lang/cargo#12707) - Shortest path (rust-lang/cargo#12678) - doc/reference/manifest: Adjust `keywords` description (rust-lang/cargo#12705) - Cargo add displays either feature list or summarized count (rust-lang/cargo#12702) - SemVer: Update documentation about removing optional dependencies (rust-lang/cargo#12687) - publish.py: Remove obsolete `sleep()` calls (rust-lang/cargo#12686) - generalise suggestion on abiguous spec (rust-lang/cargo#12685) - util/toml: Remove duplicate `serde(rename)` attributes (rust-lang/cargo#12682) r? ghost
What does this PR try to resolve?
This adds some enhancements to
cargo clean
that fell out as a result of some refactorings in #12634 for supporting an interface for cleaning from other places in cargo, and these were relatively easy to add and assist with testing in #12634.The changes are:
--dry-run
CLI option which will print whatcargo clean
will delete without deleting it. NOTE This PR makes the flag insta-stable. I don't figure there is too much that can be learned about it keeping it unstable, though we could change that. Add cache garbage collection #12634 has this flag gated with-Zgc
.cargo clean
operation that indicates how much was deleted.How should we test and review this PR?
Note that this PR also includes the changes from #12635 and #12637. Those commits can be dropped if those PRs are merged.
For the most part, this involves wrapping the cleaning operations in a
CleanContext
which provides an interface for performing cleaning operations. The dry run is just a flag that is checked at the deletion points. The summary data is also collected at those same points.