Commit graph

5422 commits

Author SHA1 Message Date
Eric Huss 45c5394703 Add a --dry-run option to cargo clean.
This adds a `--dry-run` option to have `cargo clean` display what it
would delete without actually deleting it.
2023-09-19 18:14:47 -07:00
bors f9335babbc Auto merge of #12707 - epage:spell, r=ehuss
chore: Fix typos

This is a repeat of #11561
2023-09-19 22:07:03 +00:00
Ed Page e4e10f2393 chore: Fix typos
This is a repeat of #11561
2023-09-19 15:28:48 -05:00
Angelo Ross 72dccecb19
Display only feature list or summarized on cargo add 2023-09-19 13:14:44 -03:00
Ethan Brierley 9831e83fb2 generalise suggestion on abiguous spec
Fixes #12433
2023-09-18 16:34:17 +01:00
bors 695416e8d8 Auto merge of #12660 - epage:dry, r=weihanglo
feat(cli): Add '-n' to dry-run

This came from #12638 and my many small frustrations from wanting to use `-n` and not being able to.

We do not have any existing `-n` flags for this to be confused with.

I would wager that `-n` is such an entrenched short flag in build tools that it would not make sense for us to use it with any other flag.

For a survey of where `-n` is used as a short, see https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table
2023-09-18 02:53:19 +00:00
bors 7149418ed3 Auto merge of #12649 - arlosi:cred-stable, r=weihanglo
feat: stabilize credential-process and registry-auth

Stabilization PR for `registry-auth` and `credential-process`.

Tracking approval of this stabilization is done in the via the FCP in [#8933](https://github.com/rust-lang/cargo/issues/8933#issuecomment-1711990123). This PR is here to help reviewers of the FCP.

* Stabilizes `registry-auth` and `credential-process`
* Makes authenticated registries require a credential provider
* Adds stable documentation for credential providers and authenticated registries

Closes #8933
Closes #10474
2023-09-18 01:17:44 +00:00
bors 41cef471d0 Auto merge of #12677 - weihanglo:registry-or-index, r=hi-rustin
refactor: use `RegistryOrIndex` enum to replace two booleans
2023-09-17 15:19:48 +00:00
Arlo Siemsen d345ca212f feat: stabilize credential-process and registry-auth 2023-09-16 22:40:45 -05:00
Weihang Lo e883054c59
test: verify publish failed with --index and the only implicit allowed registry
The message is misleading and shouldn't proceed when `--index` presents.
2023-09-16 00:48:41 +08:00
Weihang Lo e57ce13da8
refactor: --registry always conflicts with --index
Move the validation upfront to clap
2023-09-15 22:33:27 +08:00
Weihang Lo 1f172e4b76
refactor: extract registry and index arg for reuse 2023-09-15 18:30:28 +08:00
Arlo Siemsen 8f18f2bdc8 fix: emit a warning when a credential provider alias shadows a built-in provider 2023-09-14 14:33:59 -05:00
bors 5c84ce06f0 Auto merge of #12662 - Angelin01:limit-cargo-add-feature-print, r=weihanglo
Limit cargo add feature print
2023-09-14 13:19:16 +00:00
Angelo Ross 9928689d2c
Limit features printed during cargo add 2023-09-14 08:36:44 -03:00
Ed Page 82f9bd330e feat(spec): Allow partial versions when unambigious
This was proposed in #12425 to help improve usability of the existing
`cargo update` when dealing with the added workflows.
2023-09-13 22:00:00 -06:00
Ed Page 9008647ae2 test(clean): Verify spec version parsing 2023-09-13 21:59:28 -06:00
Ed Page 396298200d test(profile): Verify spec version parsing 2023-09-13 21:59:28 -06:00
Angelo Ross 3a40df85d6
Showcase output with too many features 2023-09-13 11:58:48 -03:00
Ed Page 033e06a1cc feat(cli): Add '-n' to dry-run
This came from #12638 and my many small frustrations from wanting to use
`-n` and not being able to.

We do not have any existing `-n` flags for this to be confused with.

I would wager that `-n` is such an entrenched short flag in build tools that it would
not make sense for us to use it with any other flag.

For a survey of where `-n` is used as a short, see
https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table
2023-09-12 13:42:00 -05:00
Jacob Finkelman dcde7eb316 move pre-release specific error message 2023-09-12 16:06:29 +00:00
loloicci 7880215265 fix error message trying patch non-existing package with prerelease version 2023-09-12 15:57:29 +00:00
loloicci c29c25be2e test error message trying patch non-existing package with prerelease version 2023-09-12 15:57:22 +00:00
Ed Page 385dfb6298 test(registry): Show current too-new schema error
This reproduces the problem in #10623.
2023-09-11 16:19:15 +00:00
Ed Page 293b71a961 test(registry): Provide more room from tests conflicting with reality 2023-09-11 16:19:15 +00:00
bors c2d26f32d3 Auto merge of #12578 - epage:help, r=weihanglo
feat(help): Add styling to help output

### What does this PR try to resolve?

Try to make `--help` output easier to parse by using terminal styling

Screenshots:

![Screenshot from 2023-09-06 09-57-11](https://github.com/rust-lang/cargo/assets/60961/61069af4-ef05-40ad-9240-fedea44d4c71)

![Screenshot from 2023-09-06 09-57-21](https://github.com/rust-lang/cargo/assets/60961/d2e69024-42aa-47c0-ad0f-24e43551b8db)

![Screenshot from 2023-09-06 09-57-36](https://github.com/rust-lang/cargo/assets/60961/e3d895e2-745f-48c6-9e84-d6fb67198d6d)

*(`nargo` is my shell script wrapping `cargo run --manifest-path cargo/Cargo.toml`)*

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

At this time, the only styling snapshotting library I know of is a pain to use, so testing this requires manually running the commands which I did.  Screenshots are included for easier evaluation of the general idea.

Snapshotting of the plain text output ensures we don't have accidental formatting regressions from this change since the formatting isn't as obvious from looking at the code.

### Additional information

Traditionally, cargo has disabled clap's styled output.  My assumed
reason is that cargo mixes custom help output with auto-generated and
you couldn't previously make it all styled.
Clap 4.2 allowed users to pass in strings styled using ANSI escape
codes, allowing us to pass in styled text that matches clap, unblocking this.  In clap
4.4.1, clap gained the ability for the user to override the style.

In this PR, I decided to use the new 4.4.1 feature to style clap's
output to match the rest of cargo's output.  Alternatively, we could use
a more subdue style that clap uses by default.

I used the `color-print` crate to allow something almost html-like for styling `&static str`.  Alternatively, we could directly embed the ANSI escape codes harder to get write, harder to inspect), or we could do the styling at runtime and enable the `string` feature in clap.

I decided to *not* style `Arg::help` messages because
- It might be distracting to have the descriptions lit up like a
  christmas tree
- It is a lot more work

The one exception I made was for `--list` since it is for a
psuedo-command (`...`) and I wanted to intentionally draw attention to
it.

#12593 made styling of `cargo -h` cleaner imo.
#12592 and #12594 were improvements I noticed while doing this.
2023-09-11 06:25:47 +00:00
bors 2fc85d15a5 Auto merge of #12648 - epage:lint, r=weihanglo
feat: Stabilize lints

Fixes #12115
2023-09-09 01:49:46 +00:00
bors 8bd32310f5 Auto merge of #12631 - Eh2406:strip_prefix, r=epage
Ues strip_prefix for cleaner code

### What does this PR try to resolve?

In https://github.com/rust-lang/cargo/pull/12629#pullrequestreview-1614154046 Ed pointed out how much cleaner the code can be using `strip_prefix`, so I found a bunch more places where we should be using it.

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

Internal refactor and test still pass.
2023-09-08 20:05:02 +00:00
Jacob Finkelman eb188831da
add a missing is:
Co-authored-by: Eric Huss <eric@huss.org>
2023-09-08 15:14:10 -04:00
Ed Page e539380512 feat: Stabilize lints
Fixes #12115
2023-09-08 10:44:00 -05:00
Arlo Siemsen 803fd6909c fix: don't print _TOKEN suggestion when not applicable
Cargo should not suggest the _TOKEN environment variable
when the cargo:token provider isn't available
2023-09-07 21:14:50 -05:00
Jacob Finkelman 44666f7377 Ues strip_prefix for cleaner code 2023-09-07 17:57:28 +00:00
Weihang Lo e575448574
refactor: flatten module path of SourceId 2023-09-07 21:06:35 +08:00
Weihang Lo b6c4e47cc0
refactor: put Source trait under cargo::sources 2023-09-07 21:06:34 +08:00
Eric Huss f49b038a3f Error out if cargo clean --doc is mixed with -p.
Currently the `-p` is ignored. This should help with any confusion
about the interaction of different flags.
https://github.com/rust-lang/cargo/issues/8790 is tracking to fix this.
2023-09-06 21:42:38 -07:00
bors d9a4cf1938 Auto merge of #12626 - arlosi:cred-error-both, r=weihanglo
fix: improve warning for both token & credential-provider

Cargo issues a warning when both a `credential-provider` and a `token` are configured for a registry.

This change removes the warning if the `credential-provider` is `cargo:token` since that *will* use the token. The warning message text is also tweaked to include the name of the `credential-provider` that's overriding the token.
2023-09-06 18:02:59 +00:00
Arlo Siemsen 3f004c613c fix: improve error for token & provider 2023-09-06 10:10:02 -05:00
hi-rustin 63ccc35642 Add skip gc glob profile test 2023-09-06 12:51:39 +08:00
bors d14c85f4e6 Auto merge of #12602 - epage:resolver, r=Eh2406
fix(resolver): Make resolver behavior independent of package order

This address one of the problems mentioned in #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.

This should not affect `Cargo.lock` at rest, so no upgrade compatibility concerns.

This just allows more packages to be considered available to change which can prevent unclear failures.

The main case I can think of that this does something "undesirable" is when wanting to prevent another "bug" from manifesting: the updating of git dependencies when updating workspace members (#12599).  I think I'm ok with that as that needs to be looked into separately.
2023-09-05 22:28:10 +00:00
Arlo Siemsen e58b84d35e breaking change(cargo-credential)
Changes the JSON format for cache:expires
2023-09-05 15:22:27 -05:00
Arlo Siemsen b8099be284 fix: make more credential JSON fields skip_serializing if None 2023-09-05 13:31:23 -05:00
bors 5f40a97e5c Auto merge of #12618 - weihanglo:cleanup-170-debuginfo, r=Muscraft
test: new options of debuginfo are no longer unstable
2023-09-03 16:52:20 +00:00
Weihang Lo 63be1e0d8b
test: new options of debuginfo are no longer unstable 2023-09-01 16:19:47 +01:00
Ed Page e46379a7f3 fix(remove): Include 'cargo help' suggestion in -h 2023-09-01 09:30:00 -05:00
Ed Page 802cb380ed fix(cli): Be more specific in what is needed 2023-08-31 08:56:16 -05:00
Ed Page adea3d148e fix(cli): Help people find possible --target values 2023-08-31 08:55:36 -05:00
Ed Page b87c9323bb refactor(cli): Manually implement missing arg error for --target 2023-08-30 20:42:45 -05:00
Ed Page 801b223135 test(cli): Show existing --target behavior 2023-08-30 20:34:42 -05:00
Ed Page a78bba7a92 fix(manifest): Improve error on good pre-release 2023-08-30 16:42:08 -05:00
Ed Page 9fb8128d9e test(manifest): Verify error on good pre-release 2023-08-30 16:42:08 -05:00