14648 Commits

Author SHA1 Message Date
renovate[bot]
a63bc76577
chore(deps): update alpine docker tag to v3.18 2023-08-01 02:18:33 +00:00
bors
29a6f2fab2 Auto merge of #12424 - arlosi:credential-thiserror, r=arlosi
Use thiserror for credential provider errors

### What does this PR try to resolve?
Errors from credential providers currently must a single string. This leads to a lot of `.map_err(|e|cargo_credential::Error::Other(e.to_string())`, which loses the `source()` of these errors.

This changes the `cargo_credential::Error` to use `thiserror` and adds a custom serialization for `std::error::Error` that preserves the source error chain across serialization / deserialization.

A unit test is added to verify serialization / deserialization.
2023-07-31 22:00:41 +00:00
Arlo Siemsen
70b584e401 Add serde(other) to credential protocol enums for future proofing 2023-07-31 16:37:33 -05:00
Arlo Siemsen
7918c7fc7b Remove from impls 2023-07-31 16:10:56 -05:00
bors
8d1d20d129 Auto merge of #12422 - obi1kenobi:patch-2, r=epage
Clarify in `--help` that `cargo test --all-targets` excludes doctests

Per my proposal here: https://github.com/rust-lang/cargo/issues/6669#issuecomment-1658593167

I tried to keep the edit minimalistic to match the surrounding style.

If the maintainers are amenable to it, I think it could also be useful to do one or more of:
- Offer concrete guidance on what to do to run actually-all tests (`--all-targets` then separately `--doc`).
- Link to the issue at: https://github.com/rust-lang/cargo/issues/6669
- Mention that `cargo test` without `--all-targets` runs doctests by default, which seems not immediately obvious.

I'd be happy to attempt to add any of the above that the maintainers feel would be a good fit here.
2023-07-31 20:14:58 +00:00
Predrag Gruevski
2f59b20df6 Mention that cargo test --all-targets excludes doctests
Per my proposal here: https://github.com/rust-lang/cargo/issues/6669#issuecomment-1658593167

I tried to keep the edit minimalistic to match the surrounding style.

If the maintainers are amenable to it, I think it could also be useful to do one or more of:
- Offer concrete guidance on what to do to run actually-all tests (`--all-targets` then separately `--doc`).
- Link to the issue at: https://github.com/rust-lang/cargo/issues/6669
- Mention that `cargo test` without `--all-targets` runs doctests by default, which seems not immediately obvious.

I'd be happy to attempt to add any of the above that the maintainers feel would be a good fit here.
2023-07-31 20:09:24 +00:00
Arlo Siemsen
a81d558941 Use thiserror for credential provider errors 2023-07-31 13:45:08 -05:00
Arlo Siemsen
5321146c7e Add serde(default) to cargo-credential RegistryInfo headers 2023-07-31 13:44:57 -05:00
bors
c91a693e79 Auto merge of #12418 - weihanglo:help-text, r=ehuss
fix: align `cargo --help` text
2023-07-31 00:26:46 +00:00
Weihang Lo
a6029902ff
fix: align cargo --help text 2023-07-31 01:08:14 +01:00
bors
9fe58acfb7 Auto merge of #12411 - weihanglo:issue/12404, r=ehuss
fix: normalize relative git submodule urls with `ssh://`
2023-07-30 17:05:18 +00:00
Weihang Lo
8a4d04414e fix: normalize relative git submodule urls with ssh://
Git only assumes a submodule URL is a relative path if it starts with `./`
or `../` [^1]. To fetch the correct repo, we need to construct an aboslute
submodule URL.

At this moment it comes with some limitations:

* GitHub doesn't accept non-normalized URLs wth relative paths.
  (`ssh://git@github.com/rust-lang/cargo.git/relative/..` is invalid)
* `url` crate cannot parse SCP-like URLs.
  (`git@github.com:rust-lang/cargo.git` is not a valid WHATWG URL)

To overcome these, this patch always tries `Url::parse` first to normalize
the path. If it couldn't, append the relative path as the last resort and
pray the remote git service supports non-normalized URLs.

See also rust-lang/cargo#12404 and rust-lang/cargo#12295.

[^1]: <https://git-scm.com/docs/git-submodule>
2023-07-30 10:04:32 -07:00
bors
fbf29f0f10 Auto merge of #12416 - weihanglo:helptext, r=ehuss
test: relax help text assertion
2023-07-30 13:54:30 +00:00
Weihang Lo
b59527901d
test: relax help text assertion
When running test in rust-lang/rust via `./x test src/tool/cargo`,
there is no rustup integrated.
2023-07-30 07:42:04 +01:00
bors
1680ab508e Auto merge of #12413 - weihanglo:tweak-panic-msg, r=ehuss
test: relax assertions of panic handler message format
2023-07-29 22:50:14 +00:00
bors
c86366091b Auto merge of #12399 - epage:normalize, r=weihanglo
fix(package): Recognize and normalize `cargo.toml`

### What does this PR try to resolve?

This solution is a blend of conservative and easy
- Normalizes `cargo.toml` to `Cargo.toml` on publish
  - Ensuring we publish the `prepare_for_publish` version and include `Cargo.toml.orig`
  - Avoids dealing with trying to push existing users to `Cargo.toml`
- All other cases of `Cargo.toml` are warnings
  - We could either normalize or turn this into an error in the future
  - When helping users with case previously, we've only handle the `cargo.toml` case
  - We already should have a fallback in case a manifest isn't detected
  - I didn't want to put in too much effort to make the code more complicated to handle this

As a side effect, if a Linux user has `cargo.toml` and `Cargo.toml`, we'll only put one of them in the `.crate` file.  We can extend this out to also include a warning for portability for case insensitive filesystems but I left that for after rust-lang/cargo#12235.

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

A PR at a time will show how the behavior changed as the source was edited

This does add a direct dependency on `unicase` to help keep case-insensitive comparisons easy / clear and to avoid riskier areas for bugs like writing an appropriate `Hash` implementation.  `unicase` is an existing transitive dependency of cargo.

### Additional information

Fixes #12384

[Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/.60cargo.2Etoml.60.20on.20case.20insensitive.20filesystems)
2023-07-29 21:55:49 +00:00
Weihang Lo
b9e70ec0a2
test: relax assertions of panic handler message format 2023-07-29 17:12:46 +01:00
bors
e9999571f6 Auto merge of #12407 - keith:ks/clarify-lto-setting-passing-clinker-plugin-lto, r=ehuss
Clarify `lto` setting passing `-Clinker-plugin-lto`

Previously this document implied that the `lto` setting only controlled `-C lto` but in some cases it can also pass `-C linker-plugin-lto`

1b3eb297f9/src/cargo/core/compiler/mod.rs (L1234)
2023-07-28 18:03:39 +00:00
bors
ff6ef63618 Auto merge of #12408 - poliorcetics:ab/missed-strip-variable-doc, r=weihanglo
doc: add missing reference to `CARGO_PROFILE_<name>_STRIP` in environment variables docs

The doc for the env var was added in b6d1979683 but was forgotten in env vars
2023-07-28 09:48:02 +00:00
Alexis (Poliorcetics) Bourget
ab4a7492bc doc: add missing reference to CARGO_PROFILE_<name>_STRIP in environment variables docs
The doc for the env var was added in b6d1979683 but was forgotten in env vars
2023-07-28 11:44:55 +02:00
Keith Smiley
38d92656cb
Clarify lto setting passing -Clinker-plugin-lto
Previously this document implied that the `lto` setting only controlled
`-C lto` but in some cases it can also pass `-C linker-plugin-lto`

1b3eb297f9/src/cargo/core/compiler/mod.rs (L1234)
2023-07-27 16:03:53 -07:00
bors
1b3eb297f9 Auto merge of #12406 - ehuss:update-curl, r=epage
Update curl-sys to pull in curl 8.2.1

There were several regressions in 8.2.0. I'm not certain how much they affect cargo, but some of them look concerning.
Changelog: https://curl.se/changes.html#8_2_1
Summary: https://daniel.haxx.se/blog/2023/07/26/curl-8-2-1/
2023-07-27 18:02:18 +00:00
Eric Huss
d711c12535 Update curl-sys to pull in curl 8.2.1 2023-07-27 10:55:18 -07:00
Ed Page
cc6b6c9584 fix(package): Avoid multiple package list entries
To keep things simple, especially in getting a `Hash` implementation
correct, I'm leveraging `unicase` for case-insensitive
comparisons which is an existing dependency and I've been using for
years on other projects.

This also opens the door for us to add cross-platform compatibility
hazard warnings about multiple paths that would write to the same
location on a case insensitive file system.  I held off on that because
I assume we would want #12235 first.

This does mean we can't test the "no manifest" case anymore because the
one case (no pun intended) I knew of for hitting it is now gone.
2023-07-26 11:02:47 -05:00
bors
263d24baca Auto merge of #12388 - zvolin:docs-workspace-resolver, r=epage
docs: raise awareness of resolver used inside workspace

Workspaces by default use the resolver in version 1. It's been some time already since the 2021 edition which made version 2 a default for alone packages, but yet most of the projects that make a use of the workspaces still depends on  an old resolver.

By being explicit about the resolver tag inside the workspace we can lower the usage of older resolver for the new projects.

This can raise the awareness of this behavior and prevent issues like https://github.com/rust-lang/cargo/issues/12387. I also wasn't aware of this behavior before while not being so new to Rust, and we have the resolver 2 for good reasons, so I think we should be more explicit about it in the documentation.
When someone looks for the 'how to make cargo workspace' answers, he's unlikely to get to the `Dependency Resolution` section at the same time, he'll likely just copy paste the workspace example from the `Workspaces` and call it a day, yet extending the usage of an old resolver and not benefiting from the new one.
2023-07-26 15:29:49 +00:00
Maciej Zwoliński
ddfa20b208
Remove last resolver leftover 2023-07-26 17:15:13 +02:00
Ed Page
9b14e39cd7 test(package): Verify mixed-case Cargo.toml 2023-07-26 10:10:21 -05:00
bors
54dfa98bbe Auto merge of #12401 - weihanglo:bump-home, r=epage
chore: update `home` to 0.5.7
2023-07-26 14:20:39 +00:00
Weihang Lo
46bf05dcaf
chore: update home to 0.5.7 2023-07-26 11:26:49 +01:00
Maciej Zwoliński
f03b762f31
Remove the resolver from all other examples 2023-07-25 23:55:53 +02:00
Maciej Zwoliński
ca89fafa91
move the guideline under virtual manifest section 2023-07-25 23:55:27 +02:00
bors
c33b132e19 Auto merge of #12400 - ehuss:update-curl, r=epage
Update curl-sys to pull in curl 8.2.0

This is a routine update to curl-sys 0.4.64, updating curl from 8.1.2 to 8.2.0.
Changelog: https://curl.se/changes.html#8_2_0
2023-07-25 17:36:41 +00:00
Eric Huss
9a5ed74983 Update curl-sys to pull in curl 8.2.0 2023-07-25 08:53:11 -07:00
bors
e2fbcd9f77 Auto merge of #11912 - epage:help, r=ehuss
test(cli): Track --help output

### What does this PR try to resolve?

This makes it easier to evaluate the usability of PRs, like #11905

This follows the pattern of `cargo add` and `cargo remove` of putting these ui tests in `cargo_<cmd>/` directories.  `init` didn't follow this pattern, so it was renamed to `cargo_init/`.  `cargo_config.rs` was going to conflict with this, it was merged in.

We can evaluate other `<cmd>.rs` files at a later point and consolidate.

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

The main risks are
- Are all files linked together (`main.rs` -> `<cmd>/mod.rs` -> `<cmd>/<help>.rs`
- Are all `help/mod.rs`s pointing to the right command
2023-07-24 23:43:05 +00:00
Ed Page
5101372312 test(cli): Track --help output
This makes it easier to evaluate the usability of PRs, like #11905
2023-07-24 17:12:20 -05:00
Ed Page
3166e5f614 fix(package): Warn when manifest is not more generally found
Being a bit cautious about not turning this into an error since this is
most likely because of case insensitive filesystems.
2023-07-24 16:49:38 -05:00
Ed Page
f4c97b24a8 test(package): Verify the no-manifest case 2023-07-24 16:41:15 -05:00
Ed Page
bbb6aff67a fix(package): Normalize cargo.toml to Cargo.toml for windows 2023-07-24 16:29:14 -05:00
Ed Page
5dd39df6f1 test(package): Verify cargo.toml behavior 2023-07-24 16:13:21 -05:00
bors
55281fd3ee Auto merge of #12398 - epage:cargo-config, r=weihanglo
refactor(test): Move cargo-config into a dir

This is split out of #11912 and is prep for adding more UI tests.

Generally our UI tests are in a directory named after the full cargo command (`cargo config`).  These tend to use `snapbox`.

Here we are tests for the `cargo config` command not written by `snapbox` in a `cargo_config.rs` file.  This conflicts with adding snapbox UI tests later in a `cargo_config/` folder.  Upon looking at this file, it appears to be UI tests, so I think it would make sense to move them into the `cargo_config/` folder.  Definitely wouldn't make sense to move them into `config.rs` since that is general config testing.
2023-07-24 20:14:19 +00:00
Ed Page
f06911cb90 refactor(test): Move cargo-config into a dir
This is split out of #11912 and is prep for adding more UI tests.

Generally our UI tests are in a directory named after the full cargo
command (`cargo config`).  These tend to use `snapbox`.

Here we are tests for the `cargo config` command not written by
`snapbox` in a `cargo_config.rs` file.  This conflicts with adding
snapbox UI tests later in a `cargo_config/` folder.  Upon looking at this
file, it appears to be UI tests, so I think it would make sense to move
them into the `cargo_config/` folder.  Definitely wouldn't make sense to
move them into `config.rs` since that is general config testing.
2023-07-24 14:47:29 -05:00
bors
ac49a62475 Auto merge of #12397 - epage:cargo-init, r=weihanglo
refactor(tests): Name init ui tests more consistently

Currently, the UI tests are
- `cargo add`
- `cargo new`
- `cargo remove`
- `init`

One of these is not like the others. This change renames `init` to `cargo_init` to suggest it is the UI tests for the `cargo init` command, rather than `init` functionality.
2023-07-24 19:16:32 +00:00
Ed Page
79469f3019 refactor(tests): Name init ui tests more consistently
Currently, the UI tests are
- `cargo add`
- `cargo new`
- `cargo remove`
- `init`

One of these is not like the others. This change renames `init` to
`cargo_init` to suggest it is the UI tests for the `cargo init` command,
rather than `init` functionality.
2023-07-24 13:39:37 -05:00
bors
7ac9416d82 Auto merge of #12396 - weihanglo:serde-derive, r=epage
fix(cargo-credential): should enable feature `serde/derive`
2023-07-24 14:29:38 +00:00
Weihang Lo
9913287a5c
fix(cargo-credential): should enable feature serde/derive 2023-07-24 15:18:44 +01:00
bors
7c82ff2e06 Auto merge of #12280 - weihanglo:git-ref-ambiguity, r=ehuss
fix: encode URL params correctly for SourceId in Cargo.lock

We use [`form_urlencoded::byte_serialize`](https://docs.rs/form_urlencoded/1.2.0/form_urlencoded/fn.byte_serialize.html), which is re-exported by `url` crate. Tests are copied from <https://github.com/rust-lang/cargo/pull/11086>. Kudos to the original author!
2023-07-23 19:01:50 +00:00
bors
af8643c5a4 Auto merge of #12392 - tmfink:doc-paths-overrides, r=weihanglo
docs: format config override caveat as a note
2023-07-23 17:55:56 +00:00
Travis Finkenauer
ccfaffc81b docs: format config override caveat as a note 2023-07-23 09:53:54 -07:00
bors
a7b6a3c46f Auto merge of #12334 - arlosi:cred-ext, r=ehuss
credential provider implementation

The current credential process protocol only allows sending the credential without any additional information. This changes the protocol in two important ways: Cargo will tell the credential provider what the token is needed for, and the credential provider can tell Cargo how the token can be used.

Since the credential provider knows why Cargo needs a token (`publish` for example), it can produce a signed token specifically for that operation. This would enable a credential process to produce an asymmetric token, or a token with restricted scope such as PASETO or Biscuit.

The credential process can also indicate back to Cargo if the token can be cached in-memory for subsequent requests. For example, if a credential provider integrates with an SSO identity provider that provides short-lived tokens, Cargo will only continue to use the token while it is valid.

### Summary of changes
* Rename `credential-process` to `credential-provider` in config.
* Add a new line-oriented JSON protocol for communicating with external credential providers via stdin/stdout.
* Allow built-in credential providers to run in the Cargo process.
* Move support for asymmetric tokens (RFC3231) into a built-in credential provider (`cargo:paseto`).
* Change the unstable key for asymmetric tokens from `registry-auth` to `credential-process`
* Add a new built-in provider to represent the current config/token based system (`cargo:token`).
* Add a new built-in provider for the a "basic" provider that prints only the token on stdout (`cargo:basic`).
* Create a new config key for the fallback credential providers (`registry.credential-providers`) as a list.
* The provider for `crates.io` no longer also acts as a fallback for other registries.
* Adds a `[credential-alias]` table for defining aliases of credential providers.
* Collect all headers from `http_registry` requests, passing them through to the cred provider.

Everything remains unstable under the `-Zcredential-process` flag.

### How to review this:
I recommend starting with the changes in `unstable.md` for a more detailed description.

### Open questions
* [x] Should we pass all the HTTP headers rather than just `www-authenticate`
2023-07-22 17:31:48 +00:00
Arlo Siemsen
6151a4152b Send all headers to cred provider 2023-07-21 17:30:01 -05:00