Commit graph

83 commits

Author SHA1 Message Date
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
Ed Page
80225bbf46 test(update): Verify --workspace behavior
Looks like `--workspace` and `-p <workspace-member>` behave differently.
2023-11-14 12:05:19 -06:00
Jacob Finkelman
7997306a0b restore error message 2023-11-06 20:16:26 +00:00
Jacob Finkelman
2352cbd1f9 add a test 2023-11-06 20:13:56 +00:00
David Tolnay
985e1eeef5
Do not call it "Downgrading" when difference is only build metadata 2023-10-09 13:53:47 -07:00
David Tolnay
4d1bf29a2c
Add test of update with version that differ only in build metadata 2023-10-09 10:36:46 -07:00
Ed Page
0af2f65ce8 fix(resolver): Make resolver behavior independent of package order
This addresses the ordering issue of for one of the problems from #12599.

The intent behind the `path_pkg` check is to make sure we update
workspace members in the lockfile if their version number changed.
In this case, we don't need to recursively walk, because the change
doesn't affect dependencies.  However, we also shouldn't *prevent*
recursive walks which is what we are doing today, both for packages
marked to keep and for packages that have been "poisoned".  So we fix
this by moving that call after all recursive adds are complete so as to
not interfere with them.
2023-08-30 13:12:52 -05:00
Ed Page
2676a4ae79 test(update): Verify extra-update behavior 2023-08-30 13:07:15 -05:00
Ed Page
82d78097c8 fix(update): Clarify meaning of --aggressive as --recursive
When working on cargo-upgrade, I found the meaning of `--aggressive`
confusing and named it `--recursive` there.

Renaming this in `cargo update` (with a backwards compatible alias) was
referenced in #12425.
2023-08-29 10:18:25 -05:00
Ed Page
4bf1af0cd0 fix(update): Make -p more convenient by being positional
Generally, cargo avoids positional arguments.  Mostly for the commands
that might forward arguments to another command, like `cargo test`.
It also allows some flexibility in turning flags into options.

For `cargo add` and `cargo remove`, we decided to accept positionals
because the motivations didn't seem to apply as much (similar to `cargo
install`).

This applies the pattern to `cargo update` as well which is in the same
category of commands as `cargo add` and `cargo remove`.

As for `--help` formatting, I'm mixed on whether `[SPEC]...` should be at the top like
other positionals or should be relegated to "Package selection".  I went
with the latter mostly to make it easier to visualize the less common
choice.

Switching to a positional for `cargo update` (while keeping `-p` for
backwards compatibility) was referenced in #12425.
2023-08-23 11:57:36 -05:00
Ed Page
57762917fb fix(update): Perform error check in clap 2023-07-31 21:18:31 -05:00
Ed Page
e290ed7a02 test(update): Add a --aggressive --precise error test 2023-07-31 21:16:54 -05:00
charles-r-earp
61df6bb418 Fixed test update::update_precise_first_run. 2023-05-03 13:08:51 -07:00
Dirkjan Ochtman
20a5d2b82f Accurately show status when downgrading dependencies 2023-03-13 13:29:30 +01:00
Scott Schafer
b974cacb50 chore: update update tests to use check 2023-02-20 12:22:29 -06:00
hi-rustin
c51f8ad083 Remove warning for aggressive flag without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-30 09:08:03 +08:00
hi-rustin
71e4dbd496 Update tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-08 10:00:10 +08:00
hi-rustin
64e3991907 Remove useless log deps and add more test for precise update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:16:01 +08:00
hi-rustin
f0b5bdad65 Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:14:07 +08:00
hi-rustin
a58489dfbb Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:12 +08:00
hi-rustin
f95deaafeb Warning when precise or aggressive without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:07 +08:00
flip1995
390af27128
Add rust_metadata to SerializedPackage
After the rust_version field was stabilized in #9732 this adds the
rust_version as output to the `cargo metadata` command, so tools like
Clippy can read and use it as well.
2021-10-12 14:07:19 +02:00
Eric Huss
8fe3bde2b5 Allow cargo update --precise with metadata. 2021-09-25 10:09:13 -07:00
hi-rustin
f9a5625733 add default_run to SerializedPackage
Delete "default_run": null,
2021-06-07 14:59:57 +08:00
Eric Huss
e58c544f37 Some minor code cleanup. 2021-02-28 19:03:06 -08:00
Alex Crichton
7dd9872c13 Change git dependencies to use HEAD by default
This commit follows through with work started in #8522 to change the
default behavior of `git` dependencies where if not branch/tag/etc is
listed then `HEAD` is used instead of the `master` branch. This involves
also changing the default lock file format, now including a `version`
marker at the top of the file notably as well as changing the encoding
of `branch=master` directives in `Cargo.toml`.

If we did all our work correctly then this will be a seamless change.
First released on stable in 1.47.0 (2020-10-08) Cargo has been emitting
warnings about situations which may break in the future. This means that
if you don't specify `branch = 'master'` but your HEAD branch isn't
`master`, you've been getting a warning. Similarly if your dependency
graph used both `branch = 'master'` as well as specifying nothing, you
were receiving warnings as well. These two situations are broken by this
commit, but it's hoped that by giving enough times with warnings we
don't actually break anyone in practice.
2021-02-04 08:54:40 -08:00
bors
63d0fe4344 Auto merge of #8725 - chaaz:master, r=ehuss
Add "--workspace" to update command

My `--bin` project has CI which updates the version number in `Cargo.toml`, which it then commits. However, this means that any further cargo command (`build`, `test`, etc) will update the existing `Cargo.lock` file (updating the root version), causing some frustration for users. Furthermore, it breaks the `publish` command, which requires the repo to be current.

I've added a `sync-lockfile` command to simply update the root version in the `Cargo.lock` file to match the `Cargo.toml` in the same way that simple commands like `fetch` do. If no `Cargo.lock` file is present, and new one is generated based on the index.

This is a demo PR for Pre-RFC conversation at https://internals.rust-lang.org/t/pre-rfc-cargo-command-to-just-sync-lockfile/13119, but may become a real PR if it gets approval.
2020-12-02 01:44:30 +00:00
ayazhafiz
e831dd12a8 Publish target's "doc" setting when emitting metadata
Prior to this commit `cargo metadata` would not emit the value of a
target's "doc" setting, used by `cargo doc` to determine whether
documentation should be generated. However, this information is useful
for machine programs interested in such targets, and the information is
already made available on the internal representation of a target, so
this commit just exposes that during target serialization for emit.

cf https://github.com/deadlinks/cargo-deadlinks/issues/99
2020-11-17 19:54:17 -06:00
Charlie Ozinga
9589d2cbc2 fix: change to update -w per feedback 2020-11-06 14:44:06 -07:00
roblabla
72694e8015 Fix tests 2020-10-01 09:40:32 +00:00
Oliver Scherer
95b22d2874 Emit the test field in cargo metadata 2020-07-30 09:50:46 +02:00
Arlo Siemsen
58869e5ce6 Stop ignoring Array ordering Json comparison tests. Update tests to have sorted order. 2020-07-15 16:32:19 -07:00
Brian Chin
866d4316e1 Add support for workspace.metadata table 2020-06-05 09:32:54 -07:00