feat: add keep-path-dependencies workspace setting#545
Draft
Boshen wants to merge 1 commit into
Draft
Conversation
Some workflows pre-declare a new crate in `[workspace.dependencies]` as a path dependency before any member inherits it, so later commits can depend on it. cargo-shear flagged such entries as unused workspace dependencies. With `keep-path-dependencies = true` under `[workspace.metadata.cargo-shear]`, a `[workspace.dependencies]` entry with `path = "..."` is treated as used as long as a crate exists at the declared path. A stale entry whose crate was deleted or moved is still reported. Default behavior is unchanged. Closes #533
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #533
Some workflows pre-declare a new crate in
[workspace.dependencies]as a path dependency before any member inherits it, so later commits (which may get shuffled or backported) can depend on it. cargo-shear flagged such entries as unused workspace dependencies.This adds an opt-in workspace setting:
When enabled, a
[workspace.dependencies]entry withpath = "..."is treated as used as long as a crate exists at the declared path (<workspace-root>/<path>/Cargo.toml). A stale entry — one whose crate was deleted or moved — is still reported as unused;cargo metadatatolerates uninherited entries with nonexistent paths, so that case is reachable in practice. Default behavior is unchanged.Notes on scope and interactions:
[dependencies]still costs compile time, so those remain flagged. The setting parses but is inert under[package.metadata.cargo-shear].ignoredcheck, so an explicitignoredentry made unnecessary by this setting is reported as a redundant ignore, consistent with existing behavior.--fixkeeps entries covered by the setting and still removes stale ones.