-
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
Allow precise update to prerelease. #13626
Conversation
I don't think I will be able to give this the attention it deserves until well after Rust Nation. But from a quick perusal it looks like a really good start. Thank you! |
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.
Thanks for this patch!
Do we have tests for checking the feature gate work and doesn't leak on stable? Like prerelease would not be selected without the flag. We may already have. Need to check. |
This |
That had been my expectation |
I already changed it by the way. |
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.
Thanks for this!
Could we also have a doc update as well?
src/doc/man/cargo-update.md
Outdated
@@ -46,6 +46,9 @@ revision (such as a SHA hash or tag). | |||
While not recommended, you can specify a yanked version of a package (nightly only). | |||
When possible, try other non-yanked SemVer-compatible versions or seek help | |||
from the maintainers of the package. | |||
|
|||
It's allows you choose any compatible `pre-release` version (nightly only) even when a pre-release is not specified by a projects `Cargo.toml`. |
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.
It's allows you choose any compatible `pre-release` version (nightly only) even when a pre-release is not specified by a projects `Cargo.toml`. | |
A compatible `pre-release` version can also be specified even when the version requirement in `Cargo.toml` doesn't contain any pre-release identifer (nightly only). |
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 annotations have always been my weakness, thank you for correcting this description.
src/cargo/sources/registry/mod.rs
Outdated
.filter(|(c, _)| { | ||
if self.gctx.cli_unstable().unstable_options { |
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.
I don't know how match_prerelease
will evolve, so it's better to have a check here maybe?
.filter(|(c, _)| { | |
if self.gctx.cli_unstable().unstable_options { | |
.filter(|(c, to)| { | |
if to.is_prerelease() && self.gctx.cli_unstable().unstable_options { |
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.
Your concern makes sense.
src/cargo/sources/registry/mod.rs
Outdated
@@ -790,7 +796,13 @@ impl<'gctx> Source for RegistrySource<'gctx> { | |||
.index | |||
.query_inner(dep.package_name(), &req, &mut *self.ops, &mut |s| { | |||
let matched = match kind { | |||
QueryKind::Exact => dep.matches(s.as_summary()), | |||
QueryKind::Exact => { | |||
if self.gctx.cli_unstable().unstable_options { |
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.
Same here. We might want this check to prevent any regression in the future, if some underlying functions change.
if self.gctx.cli_unstable().unstable_options { | |
if req.is_precise() && self.gctx.cli_unstable().unstable_options { |
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.
Thanks. The only missing piece is updating the unstable doc here to -Zunstable-options
:
cargo/src/doc/src/reference/unstable.md
Line 350 in f4ea1d1
It's possible to update `my-dependancy` to a pre-release with `update -Zprecise-pre-release -p my-dependency --precise 0.1.2-pre.0`. |
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
Update cargo 9 commits in 0637083df5bbdcc951845f0d2eff6999cdb6d30a..28e7b2bc0a812f90126be30f48a00a4ada990eaa 2024-04-02 23:55:05 +0000 to 2024-04-05 19:31:01 +0000 - refactor(toml): Decouple target discovery from Target creation (rust-lang/cargo#13701) - Don't depend on `?` affecting type inference in weird ways (rust-lang/cargo#13706) - test(metadata): Show behavior with TOML-specific types (rust-lang/cargo#13703) - fix: adjust tracing verbosity in list_files_git (rust-lang/cargo#13704) - doc: comments on `PackageRegistry` (rust-lang/cargo#13698) - Switch to using gitoxide by default for listing files (rust-lang/cargo#13696) - Allow precise update to prerelease. (rust-lang/cargo#13626) - refactor(toml): Split out an explicit step to resolve `Cargo.toml` (rust-lang/cargo#13693) - chore(deps): update rust crate base64 to 0.22.0 (rust-lang/cargo#13675) r? ghost
What does this PR try to resolve?
This is a feature that attempts to support updates to pre-release versions via
cargo update --precise
.when
precise-pre-release
used, the prerelase version will be taking consider as compatible version. That said, we can update to any compatible pre-release version. The logic of checking the compatibility of pre-release versions is currently tentative and does not take many conditions into account, this part of the logic makes more sense when implemented in semver.Use
-Zunstable-options
instead of-Zprecise-pre-release
.How should we test and review this PR?
Additional information
Part of #13290