Skip to content
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

Merged
merged 1 commit into from
Apr 3, 2024
Merged

Conversation

linyihai
Copy link
Contributor

@linyihai linyihai commented Mar 22, 2024

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

@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-crate-dependencies Area: [dependencies] of any kind A-registries Area: registries A-semver Area: semver specifications, version matching, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 22, 2024
@Eh2406
Copy link
Contributor

Eh2406 commented Mar 23, 2024

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!

Copy link
Member

@weihanglo weihanglo left a 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!

src/cargo/sources/registry/mod.rs Outdated Show resolved Hide resolved
src/cargo/sources/registry/mod.rs Outdated Show resolved Hide resolved
@weihanglo
Copy link
Member

weihanglo commented Mar 23, 2024

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.

@weihanglo
Copy link
Member

This --precise <prerelease> is pretty much similar to --precise <yanked>. This make me wonder if we want just overload -Zunstable-options for these two purpose instead of a separate -Zprecise-pre-release unstable flag.

@epage
Copy link
Contributor

epage commented Mar 25, 2024

This --precise is pretty much similar to --precise . This make me wonder if we want just overload -Zunstable-options for these two purpose instead of a separate -Zprecise-pre-release unstable flag.

That had been my expectation

@rustbot rustbot added A-cli-help Area: built-in command-line help A-documenting-cargo-itself Area: Cargo's documentation A-unstable Area: nightly unstable support labels Mar 26, 2024
@linyihai
Copy link
Contributor Author

This --precise <prerelease> is pretty much similar to --precise <yanked>. This make me wonder if we want just overload -Zunstable-options for these two purpose instead of a separate -Zprecise-pre-release unstable flag.

I already changed it by the way.

Copy link
Member

@weihanglo weihanglo left a 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?

@@ -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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

Copy link
Contributor Author

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.

tests/testsuite/precise_pre_release.rs Outdated Show resolved Hide resolved
tests/testsuite/precise_pre_release.rs Outdated Show resolved Hide resolved
tests/testsuite/precise_pre_release.rs Outdated Show resolved Hide resolved
Comment on lines 755 to 756
.filter(|(c, _)| {
if self.gctx.cli_unstable().unstable_options {
Copy link
Member

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?

Suggested change
.filter(|(c, _)| {
if self.gctx.cli_unstable().unstable_options {
.filter(|(c, to)| {
if to.is_prerelease() && self.gctx.cli_unstable().unstable_options {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your concern makes sense.

@@ -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 {
Copy link
Member

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.

Suggested change
if self.gctx.cli_unstable().unstable_options {
if req.is_precise() && self.gctx.cli_unstable().unstable_options {

Copy link
Member

@weihanglo weihanglo left a 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:

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`.

@weihanglo
Copy link
Member

Thanks!

@bors r

@bors
Copy link
Collaborator

bors commented Apr 3, 2024

📌 Commit 179f2f1 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2024
@bors
Copy link
Collaborator

bors commented Apr 3, 2024

⌛ Testing commit 179f2f1 with merge 6774b85...

@bors
Copy link
Collaborator

bors commented Apr 3, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 6774b85 to master...

@bors bors merged commit 6774b85 into rust-lang:master Apr 3, 2024
21 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 6, 2024
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
@rustbot rustbot added this to the 1.79.0 milestone Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli-help Area: built-in command-line help A-crate-dependencies Area: [dependencies] of any kind A-documenting-cargo-itself Area: Cargo's documentation A-registries Area: registries A-semver Area: semver specifications, version matching, etc. A-unstable Area: nightly unstable support S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants