-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(package): detect dirty workspace manifest #15089
base: master
Are you sure you want to change the base?
Conversation
Workspace manifest dirtiness is more complicated than the other cases. We will construct dedicated tests for it in following commits.
This commits adds three tests to demonstrate that dirtiness check does not work for Cargo.toml involved with workspace inheritance. * One for basic check. If any change in workspace manifest could affect the inherited value, this should be caught as dirty. * One for broken workspace manifest in Git index. * The other is also for broken workspace manifest in Git index, but has no inherited field.
This addresses one of the corner cases of VCS dirtiness in rust-lang#14967. > Workspace inheritance — like changing `workspace.package.edition` > to `2021` would actually make member Cargo.toml dirty, > but the current dirty status check doesn't capture that. The solution here is * Retrieve workspace manifest from Git index. * Use the ws manifest from index to normalize package manifest. * Compare the difference between normalized tomls from Git index and from Git working directory. The implementation here is a bit ugly, as it exposes some internals functions to `pub(crate)`. The current implementation also has performance issues. When the workspace contains lots of members and has a dirty workspace manifest: * It adds one extra manifest parsing and normalization for checking each member. * Parsing part can be cached for the entire workspace. However normalization cannot be skipped. * It adds two TOML serializations for checking each member. * If we derive `Eq` for manifest types, we might be able to skip serializations and instead just compare them.
e7c2904
to
1a91bd3
Compare
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.
The solution here is
- Retrieve workspace manifest from Git index.
- Use the ws manifest from index to normalize package manifest.
- Compare the difference between normalized tomls from Git index and
from Git working directory.
This is a complex operation we are doing which I seriously question whether it is worth it vs something else like "its dirty if the workspace manifest is dirty" (without even bothering to check if the workspace manifest is different than the package manifest).
Similarly, we now include Cargo.lock
and that could be dirty. Would we extend the same kind of "only if it affects this one package" style check for that case?
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.
Good point. I do think this fix is a bit too convoluted to merge.
"its dirty if the workspace manifest is dirty"
This is actually a good compromise as users always have --allow-dirty
to bypass it. Guess we could start an FCP or discussion during the meeting.
Similarly, we now include
Cargo.lock
and that could be dirty. Would we extend the same kind of "only if it affects this one package" style check for that case?
Ooops. I would rather not. Also we have --lockfile-path
, which makes the entire story worse 😞.
What does this PR try to resolve?
This addresses one of the corner cases of VCS dirtiness in #14967.
The solution here is
from Git working directory.
The implementation here is a bit ugly, as it exposes some internals
functions to
pub(crate)
.The current implementation also has performance issues. When the
workspace contains lots of members and has a dirty workspace manifest:
checking each member.
However normalization cannot be skipped.
Eq
for manifest types, we might be able to skipserializations and instead just compare them.
How should we test and review this PR?
Three tests are added to demonstrate that dirtiness check does not
work for Cargo.toml involved with workspace inheritance.
the inherited value, this should be caught as dirty.
no inherited field.
Additional information