115 Commits

Author SHA1 Message Date
Ross Sullivan
92d9a94d02
chore: Migrated testsuite to testsuite::prelude 2025-06-25 22:37:24 +09:00
Weihang Lo
c3409d5425
refactor: clean up clippy::perf lint warnings
The `clippy::perf` lint group is fairly useful for catching bad
practices that might hurt performance marginally.

This PR fixes most of them except `clippy::large_enum_variant`,
which doesn't feel right at this moment and need more researches.

Anyway, overall this PR should be good.
2025-06-04 14:23:12 -07:00
Pyrode
2ba61b9dfc update: Added error message for when v is prefixed with version 2025-05-03 22:35:44 +05:30
Pyrode
ef3e28d371 test(update): Added test for prefixed v in version 2025-05-03 22:33:00 +05:30
todd
11f84a964c fix: use Registry::describe_source to fix error message and related test cases
`Registry::describe_source` will be used as default error message, but if the message
come from `Registry::describe_source` is empty, then it uses `SourceId` message
2024-10-25 00:35:30 +08:00
Ed Page
fd743dacdc fix(resolve): Don't list transitive, incompatible dependencies as available
This is part of #13908
2024-09-19 11:42:33 -05:00
Ed Page
ded3f004a4 fix(resolve): Generalize term describing updates
`latest` was easy.  `latest compatible` was ok.  But how do I talk about
"latest compatible with your MSRV".  That gets messy.
2024-08-30 09:26:56 -05:00
Ed Page
353cd87cea fix(resolve): With latest message, differentiate actionable updates
Instead of always listing the absolute latest version as a warning
color, we now differentiate
- compatible updates are always actionable
- incompatible, direct deps are always actionable

These get reported and made yellow while non-actionable messages are
unstyled.

This is not intended as *the* solution for #13908 though it makes
improvements in that direction.
This is prep work for improved MSRV reporting where we will
differentiate this further by only considering MSRV-compatible updates as actionable
(or rustc-compatible when not using MSRV-aware reslver).

I just used a broad stroke to say "compatible" in the message means "semver
compatible" and use `^`
- We could focus on "compatible with dependent version reqs" which is
  what will be most actionable but seeing if we can get away without
  having to track all in-coming version reqs.
- We could be more nuanced in language but the more verbose we are, the
  more we take away from higher priority messages
2024-08-27 13:40:03 -05:00
Ed Page
d2ec764995 fix(resolve): Dont show locking workspace members
This is for `cargo generate-lockfile` and when syncing the lockfile with
the manifest.
We still show it for `cargo update` because of `cargo update
--workspace`.

We hacked around this previously by filtering out the `num_pkgs==1` case
for single packages but this didn't help with workspaces.
2024-08-22 16:57:06 -05:00
bors
a7917fdc3a Auto merge of #14250 - linyihai:update-breaking-prerelease, r=weihanglo
Don't downgrade on prerelease `VersionReq` when update with --breaking.

### What does this PR try to resolve?
Do nothing with prerelease when update with `--breaking`.

Fixes https://github.com/rust-lang/cargo/issues/14178

### How should we test and review this PR?

Previous commit add a test, next commit to fix and update.

### Additional information
2024-07-24 19:09:05 +00:00
Ed Page
bb5488c9a0 tests: Update for snapbox deprecations 2024-07-24 10:42:50 -05:00
Lin Yihai
9e2701aedb fix: Don't downgrade with update --breaking if VersionReq is prerelease 2024-07-23 14:38:36 +08:00
Lin Yihai
89b0119772 test: Add test about update --breaking on prerelease 2024-07-23 14:38:36 +08:00
Tor Hovland
57622d7939 fix: Improved error message when update --breaking invalid spec. 2024-07-21 10:06:15 +02:00
Tor Hovland
f41bdc142b fix: update --breaking now handles mixed renaming and pinning. 2024-06-27 09:12:10 +02:00
Tor Hovland
f096a9446f fix: update --breaking now understands package@version. 2024-06-27 09:12:10 +02:00
Tor Hovland
8882d0504e test: More update --breaking tests. 2024-06-27 09:12:10 +02:00
Tor Hovland
abc86e24c8 refactor: Clean up test output and tracing, and introduce variable. 2024-06-27 09:12:10 +02:00
eth3lbert
c7c1462b28
test: migrate update to snapbox 2024-06-21 15:19:23 +08:00
Ed Page
dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00
Tor Hovland
031b410181 feat: Implement cargo update --breaking. 2024-06-07 09:13:28 +02:00
Tor Hovland
c694ff0b44 test: For the upcoming cargo update --breaking feature. 2024-06-07 09:12:05 +02:00
Weihang Lo
a076f7921b
feat: stabilize cargo update --precise <yanked> 2024-05-28 13:13:56 -04:00
Ed Page
bec36fce99 fix(update): Remove locking message for --precise
We aren't locking to latest.
We could customize the message for precise but it seemed a bit
excessive.
2024-04-15 13:00:34 -05:00
Ed Page
e772fc93b4 feat(update): Include a Locking message 2024-04-15 12:36:36 -05:00
Ed Page
1876326b6b feat(resolve): Tell the user the style of resovle done
This is to help with #9930

Example changes:
```diff
-[LOCKING] 4 packages
+[LOCKING] 4 packages to latest version
-[LOCKING] 2 packages
+[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
-[LOCKING] 2 packages
+[LOCKING] 2 packages to earliest versions
```

Benefits
- The package count is of "added" packages and this makes that more
  logically clear
- This gives users transparency into what is happening, especially with
  - what rust-version is use
  - the transition to this feature in the new edition
  - whether the planned config was applied or not (as I don't want it to
    require an MSRV bump)
- Will make it easier in tests to show what changed
- Provides more motiviation to show this message in `cargo update` and
  `cargo install` (that will be explored in a follow up PR)

This does come at the cost of more verbose output but hopefully not too
verbose.  This is why I left off other factors, like avoid-dev-deps.
2024-04-13 20:39:59 -05:00
Ed Page
4ab2797f36 feat(lock): Print lockfile changes on all commands 2024-03-12 13:39:56 -05:00
Ed Page
14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Ed Page
012ca52bcc fix(update): Start note/warn with lowercase 2024-02-05 10:55:01 -06:00
Ed Page
dce58dc76d fix(update): Show updates for all relevant packages 2024-02-01 14:01:07 -06:00
Ed Page
0034ea3bbf test(update): Show lack of message on old 2024-02-01 12:59:30 -06:00
Ed Page
b05dc26a08 fix(update): Help people discover how they pull in a stale dep
I put this behind `--verbose`
- To keep the output down in the standard case
- Because its assuming  most people's "behind" dependencies will be
  "Unchanged" and so that is when knowing how to look up how its pulled
  in is useful
2024-01-30 20:49:32 -06:00
Ed Page
21dfe88079 fix(update): Call out pre-releases when relevant 2024-01-30 20:16:32 -06:00
Ed Page
c89ac1f234 feat(update): Summarize unchanged packages with updates
`--verbose` will show them.

This is prep for telling the user about `--breaking` and other flags.
2024-01-30 20:16:32 -06:00
Ed Page
b4ad206205 test(update): Show behavior for missing feature 2024-01-30 20:16:32 -06:00
Ed Page
94f67d0917 test(update): Compare verbose with and without updates 2024-01-30 20:16:32 -06:00
Ed Page
a1db0b1383 fix(update): Don't bother listing pre-release
There might be casses where we want to show pre-release as this grows
but, for now, there isn't too often a case where an update is held back,
you are on a pre-release, your pre-release is updating, and you want a pre-release.
2024-01-30 20:16:32 -06:00
Ed Page
e7f1009bc4 test(update): Latest alpha is shown 2024-01-30 20:16:32 -06:00
Ed Page
47a006eeea feat(update): Show available breaking versions 2024-01-30 20:16:32 -06:00
Ed Page
f49a8f44ab test(update): Show behind on breaking 2024-01-29 20:35:53 -06:00
Weihang Lo
caeaaa529c
fix(cargo-update): once warn once for --precise <yanked>
This also tweaks the error message a bit.
2024-01-29 16:00:01 -05:00
Weihang Lo
bc5da432ef
test(cargo-update): verify `--precise <yanked> warns twice
This is not ideal and we need to track selected yanked versions.
2024-01-29 15:50:56 -05:00
Weihang Lo
3f2f4ed29b
feat(cargo-update): --precise to allow yanked versions 2024-01-21 20:14:24 -05:00
Weihang Lo
4f1e41ebe3
test(update): demonstrate not able to update --precise <yanked> 2024-01-21 14:45:35 -05:00
bors
350098d5ef Auto merge of #13250 - weihanglo:cargo-update, r=ehuss
fix(cargo-update): `--precise` accept arbitrary git revisions
2024-01-15 17:57:47 +00:00
Weihang Lo
e6f2dfd452
test(cargo-update): verify a oid-like tag triggers a re-fetch 2024-01-04 17:43:19 -05:00
Weihang Lo
2734097f12
fix(git): represent deferred and resolved revision with an enum
`cargo update --precise` might pass in any arbitrary Git reference,
and `git2::Oid::from_str` would always zero-pad the given str if it is
not a full SHA hex string.

This introduces an enum `Revision` to represent `locked_rev`
that is either deferred or resolved to an actual object ID.
When `locked_rev` is a short ID or any other Git reference,
Cargo first performs a Git fetch to resolve it (without --offline),
and then locks it to an actual commit object ID.
2024-01-04 16:32:58 -05:00
Weihang Lo
4be3614264
test(cargo-update): --precise not work with tag or short id
This demonstrates the bug described in 13188
2024-01-04 10:56:55 -05:00
Ed Page
594c96ad51 refactor(metadata): Switch opaque ID from PackageID to PackageIDSpec 2023-12-06 08:58:56 -06:00
Ed Page
9ca6376f29 fix(resolver): Don't do git fetches when updating workspace members
Before, when running `cargo update <member>`, we'd not reuse the
previous resolve result and when the resolver started walking into the
dependencies, it would do a git fetch.

Now, we won't even try to resolve the workspace members and so we won't
look at those dependencies and do git fetch.

This will make `cargo update <workspace-member>`
match `cargo update --workspace`.
I considered whether there were other ways of handling this but I
figured aiming for consistency in approaches was the best way.
We can investigate improving those approaches separately.

There are other discrepancies in the different code paths (handling of
patches, adding sources) but I'm deferring looking over those.

Between this and #12602, this should finnally resolve #12599.

Fixes #12599
2023-11-14 13:47:10 -06:00