287 Commits

Author SHA1 Message Date
Weihang Lo
06d65a48f8
chore: bump versions of git2 and libgit2-sys 2021-01-22 23:27:44 +08:00
Weihang Lo
02b49de61c
fix: set search path before init repos 2021-01-21 14:55:30 +08:00
Dirkjan Ochtman
c221fec911 Implement support for rust-version field in project metadata 2021-01-20 11:40:41 +01:00
Matthias Krüger
8e3f97f02d reduce nesting of if x { } else { if y {} else {} } expressions by concerting to if x {} else if y {} else {} (clippy::collapsible_else_if) 2021-01-06 13:59:17 +01:00
Eric Huss
382b2519b4 Add version to credential dependencies.
I forgot to add the version in the dependency declaration for cargo-credential.
2020-12-16 12:25:59 -08:00
bors
8917837fb6 Auto merge of #8934 - ehuss:token-process, r=alexcrichton
Implement external credential process. (RFC 2730)

This adds a config setting for an external process to run to fetch the token for a registry. See `unstable.md` for more details.

As part of this, it adds a new `logout` command. This is currently gated on nightly with the appropriate `-Z` flag.

I have included four sample wrappers that integrate with the macOS Keychain, Windows Credential Manager, GNOME libsecret, and 1password. I'm not sure if we'll ultimately ship these, but I would like to. Primarily this provided a proof-of-concept to see if the design works.

**Patch Walkthrough**

This is a brief overview of the changes:

- Adds the `logout` command. With `cargo logout -Z unstable-options`, this allows removing the `token` from `.cargo/credentials`.  With `cargo logout -Z credential-process`, this launches the process with the `erase` argument to remove the token from storage.
- Credential-process handling is in the `ops/registry/auth.rs` module. I think it is pretty straightforward, it just launches the process with the appropriate store/get/erase argument.
- `ops::registry::registry()` now returns the `RegistryConfig` to make it easier to pass the config information around.
- `crates/credential/cargo-credential` is a helper crate for writing credential processes.
- A special shorthand of the `cargo:` prefix for a credential process will launch the named process from the `libexec` directory in the sysroot (or, more specifically, the `libexec` directory next to the `cargo` process). For example `credential-process = "cargo:macos-keychain"`. My intent is to bundle these in the pre-built rust-lang distributions, and this should "just work" when used with rustup. I'm not sure how that will work with other Rust distributions, but I'm guessing they can figure it out. This should make it much easier for users to get started, but does add some integration complexity.

**Questions**

- I'm on the fence about the name `credential-process` vs `credentials-process`, which sounds more natural? (Or something else?)
- I'm uneasy about the behavior when both `token` and `credential-process` is specified (see `warn_both_token_and_process` test). Currently it issues a warning and uses `token`. Does that make sense? What about the case where you have `registries.foo.token` for a specific registry, but then have a general `registry.credential-process` for the default (it currently warns and uses the token, maybe it should not warn?)?
- I am still pretty uneasy with writing FFI wrappers, so maybe those could get a little extra scrutiny? They seem to work, but I have not extensively tested them (I tried login, publish, and logout). I have not previously used these APIs, so I am not familiar with them.
- Testing the wrappers I think will be quite difficult, because some require TTY interaction (and 1password requires an online account). Or, for example in the macOS case, it has GUI dialog box where I can use my fingerprint scanner. Right now, I just build them in CI to make sure they compile.
- 1password is a little weird in that it passes the token on the command-line, which is not very secure on some systems (other processes can see these sometimes). The only alternative I can think of is to not support `cargo login` and require the user to manually enter the token in the 1password GUI. I don't think the concern is too large (1password themselves seem to think it is acceptable). Should this be OK?
- I'm a little uneasy with the design of `cargo login`, where it passes the token in stdin. If the wrapper requires stdin for user interaction (such as entering a password to unlock), this is quite awkward. There is a hack in the 1password example that demonstrates using `/dev/tty` and `CONIN$`, which *seems* to work, but I'm worried is fragile. I'm not very comfortable passing the token in environment variables, because those can be visible to other processes (like CLI args), but in some situations that shouldn't be too risky. Another option is to use a separate file descriptor/handle to pass the token in. Implementing that in Rust in a cross-platform way is not terribly easy, so I wanted to open this up for discussion first.
2020-12-14 16:22:53 +00:00
Eric Huss
69c5af8591 Add some credential manifest metadata and READMEs. 2020-12-06 11:41:12 -08:00
Eric Huss
37e9c77a33 Add docs on how cargo-credential finds the action argument. 2020-12-06 11:41:12 -08:00
Eric Huss
8ac04d1e63 Check for nul in Windows utf-16 wide-string. 2020-12-06 11:40:53 -08:00
Eric Huss
eb081ed301 Workaround fs issue in cargo publish. 2020-12-05 14:10:29 -08:00
Eric Huss
cc6df1d7a5 Implement credential-process. 2020-12-02 19:09:54 -08:00
Igor Matuszewski
aab416f6e6 Use u32/64::to/from_le_bytes instead of bit fiddling 2020-11-09 23:32:39 +01:00
Aaron Hill
939b5ff766
Bump anyhow dependency to 1.0.34 in crates-io crate
This will keep `crates-io` compiling if https://github.com/rust-lang/rust/issues/33953
is fixed. See https://github.com/dtolnay/anyhow/pull/120
2020-11-02 18:45:18 -05:00
Eric Huss
b731190daa Add a future-compatibility warning on allowed feature name characters. 2020-10-27 14:23:35 -07:00
Eric Huss
bcfdf9fbad New namespaced features implementation. 2020-10-23 16:04:41 -07:00
Weihang Lo
d613cd66c7
Merge branch 'master' into feat/glob-pattern 2020-10-18 08:48:30 +08:00
Eric Huss
1a86f232c5 Fix man page links inside option blocks. 2020-10-17 12:15:12 -07:00
Ivan Tham
a90984924d
Add help to substitute macros 2020-10-14 10:01:12 +08:00
Weihang Lo
be31989a43
test: minimal shell quote supoort for cargo-test-support 2020-10-04 22:55:50 +08:00
bors
1ffdfb70eb Auto merge of #8715 - ehuss:contrib, r=alexcrichton
Add contributor guide.

This consolidates and extends the contributor information in a single place. This is an mdbook project, along with a CI job which will build and deploy it to GitHub Pages at <https://rust-lang.github.io/cargo/contrib/>.

You can view a rendered version here: <https://ehuss.github.io/cargo/contrib/>

I don't know if this will actually be helpful to anyone, but I figured it's worth a shot.

NOTE: The CI deploy is designed to preserve the existing gh-pages content.  However, it will **delete the history** on that branch. I think that should be fine, there doesn't seem to be too much interesting stuff there.  I do have a backup in my fork, though. Some extra scrutiny on the code might be wise.  The reason it deletes the history is because deploying mdbook on every push would balloon the repository size.
2020-09-27 07:06:34 +00:00
bors
c369b8c8d8 Auto merge of #8165 - mchernyavsky:force-progress, r=ehuss
Add a term option to configure the progress bar

Closes https://github.com/rust-lang/cargo/issues/7587.
2020-09-23 21:28:14 +00:00
Eric Huss
4d40ef4ef4 Add contributor guide. 2020-09-18 14:01:51 -07:00
mchernyavsky
d649c66191 Add a term option to configure the progress bar 2020-09-16 22:32:31 +03:00
Mukund Lakshman
8d610e1d28 Display formatted output for JSON diffing in tests. 2020-09-12 17:24:53 +01:00
Alex Crichton
bf10871c32 Fix flakiness in close_output test
It looks like stdout/stderr can race as to which gets printed first, but
both are valid for this test.

Closes #8665
2020-08-31 13:15:30 -07:00
bors
964a16a28e Auto merge of #8575 - matthiaskrgr:clippy_v16, r=ehuss
clippy fixes, use matches! macro in more places
2020-08-04 03:47:51 +00:00
Matthias Krüger
f23b91190c use sort_by_key() instead of comparing by keys manually
replace format!() macro by String::from()
use eprintln() instead of manually writing to std::io::stderr
2020-08-03 22:52:01 +02:00
Eric Huss
566706e863 Fix some Windows newline behavior. 2020-08-01 12:22:14 -07:00
Eric Huss
8b878f38cd Add mdman for generating man pages. 2020-08-01 11:13:52 -07:00
Alex Crichton
dc4b695f41 Build host dependencies with opt-level 0 by default
This commit updates Cargo's build of host dependencies to build them
with optimization level 0 by default instead of matching the profile of
the final binary.

Since Cargo's inception build dependencies have, by default, been built
in a profile that largely matches the profile of the final target
artifact. Build dependencies, however, rarely actually need to be
optimized and are often executing very small tasks, which means that
optimizing them often wastes a lot of build time. A great example of
this is procedural macros where `syn` and friends are pretty heavyweight
to optimize, and the amount of Rust code they're parsing is typically
quite small, so the time spent optimizing rarely comes as a benefit.

The goal of this PR is to improve build times on average in the
community by not spending time optimizing build dependencies (build
scripts, procedural macros, and their transitive dependencies). The PR
will not be a universal win for everyone, however. There's some
situations where your build time may actually increase:

* In some cases build scripts and procedural macros can take quite a
  long time to run!
* Cargo may not build dependencies more than once if they're shared with
  the main build. This only applies to builds without `--target` where
  the same crate is used in the final binary as in a build script.

In these cases, however, the `build-override` profile has existed for
some time know and allows giving a knob to tweak this behavior. For
example to get back the previous build behavior of Cargo you would
specify, in `Cargo.toml`:

    [profile.release.build-override]
    opt-level = 3

or you can configure this via the environment:

    export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_OPT_LEVEL=3

There are two notable features we would like to add in the future which
would make the impact of a change like this smaller, but they're not
implemented at this time (nor do we have concrete plans to implement
them). First we would like crates to have a way of specifying they
should be optimized by default, despite default profile options. Often
crates, like lalrpop historically, have abysmal performance in debug
mode and almost always (even in debug builds) want to be built in
release mode. The second feature is that ideally crate authors would be
able to tell Cargo to minimize the number of crates built, unifying
profiles where possible to avoid double-compiling crates.

At this time though the Cargo team feels that the benefit of changing
the defaults is well worth this change. Neither today nor directly after
this change will be a perfect world, but it's hoped that this change
makes things less bad!
2020-07-17 12:39:41 -07: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
bors
2f4097aa6b Auto merge of #8416 - est31:remove_derive, r=alexcrichton
Remove unused serde_derive dependency from the crates.io crate
2020-06-26 16:33:12 +00:00
est31
65591e8144 Remove unused serde_derive dependency 2020-06-26 17:29:09 +02:00
CrLF0710
ad0940c9ad Add missing license field. 2020-06-20 10:03:25 +08:00
Matthias Krüger
6eefe3c236 fix clippy warnings 2020-06-04 00:55:45 +02:00
bors
5847787fef Auto merge of #8274 - Eh2406:8249-repro, r=alexcrichton
reset lockfile information between resolutions

#8249 pointed out that some kind of lockfile data was leaking between calls to the resolver. @ehuss made a reproducing test case. This PR resets the `LockedMap` data structure when calling `register_previous_locks`.

lets see if CI likes it.
fix #8249
2020-06-01 16:01:10 +00:00
Eric Huss
80e55c774b Fix tests with enoent error message on non-english systems. 2020-05-29 12:34:17 -07:00
Eh2406
8ce0d02971 confirm that it is not a bug at resolver level 2020-05-28 15:43:30 -04:00
Daniel Wagner-Hall
556c236f9a Bump to semver 0.10 for VersionReq::is_exact
This stops using `to_string` as a proxy for this now-provided precise API.

This reverts commit b71927224fd9306b2b5bd2b4f8c22268eadfeb6a and bupms the
dependency version in Cargo.toml.
2020-05-25 11:11:45 +01:00
Eric Huss
771b2bca76 Repro 2020-05-24 17:31:30 -04:00
Matthias Krüger
6694fdb677 clippy fixes 2020-05-01 01:16:30 +02:00
bors
90931d9b31 Auto merge of #8077 - faern:use-assoc-int-consts, r=ehuss
Use associated constants directly on primitive types instead of modules

This PR is in no way critical. It's more of a code cleanup. It comes as a result of me making https://github.com/rust-lang/rust/pull/70857 and search-and-replacing all usage of the soft-deprecated ways of reaching primitive type constants.

It makes the code slightly shorter, that's basically it. And showcases the recommended way of reaching these consts on new code :)
2020-04-28 01:56:59 +00:00
Dylan MacKenzie
cf57ce1574 Clear RUSTDOCFLAGS for all tests 2020-04-27 14:31:44 -07:00
bors
97d39aeaac Auto merge of #8139 - mati865:patch-1, r=ehuss
Add windows-gnu CI and fix tests

One remaining failure:
```
---- features::feature_off_dylib stdout ----
running `d:\a\1\s\target\debug\cargo.exe build --features f1`
running `d:\a\1\s\target\debug\cargo.exe run -p bar`
thread 'features::feature_off_dylib' panicked at '
Expected: execs
    but: exited with exit code: 101
--- stdout

--- stderr
   Compiling foo v0.0.1 (D:\a\1\s\target\cit\t663\foo)
   Compiling bar v0.0.1 (D:\a\1\s\target\cit\t663\foo\bar)
    Finished dev [unoptimized + debuginfo] target(s) in 0.69s
     Running `target\debug\bar.exe`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"f1"`,
 right: `"no f1"`', bar\src\main.rs:5:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\bar.exe` (exit code: 101)
', crates\cargo-test-support\src\lib.rs:833:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    features::feature_off_dylib
```

I disassembled the dylibs and `cargo run -p bar` correctly rebuilt it inside `target/debug/deps/` but did not copy it to `target/debug`. To further confirm, calling `cp target/debug/deps/foo.dll target/debug/` manually solved the issue.
Any idea?

----

I left `FIXME` in places where import lib should be added with https://github.com/rust-lang/cargo/pull/6875.

`TOOLCHAIN: nightly-x86_64-pc-windows-gnu` can be replaced with beta on Thursday.
2020-04-21 17:03:56 +00:00
Mateusz Mikuła
9f742466f1 Update tests for windows-gnu 2020-04-21 17:25:25 +02:00
bors
9d84c0c734 Auto merge of #7973 - ehuss:index-updates, r=alexcrichton
Several updates to token/index handling.

This attempts to tighten up the usage of token/index handling, to prevent accidental leakage of the crates.io token.

* Make `registry.index` config a hard error. This was deprecated 4 years ago in #2857, and removing it helps simplify things.
* Don't allow both `--index` and `--registry` to be specified at the same time. Otherwise `--index` was being silently ignored.
* `registry.token` is not allowed to be used with the `--index` flag. The intent here is to avoid possibly leaking a crates.io token to another host.
* Added a warning if source replacement is used and the token is loaded from `registry.token`.

Closes #6545
2020-04-20 19:50:40 +00:00
Eric Huss
65274ea7d5 Add a warning when using registry.token with source replacement. 2020-04-19 09:25:32 -07:00
Eric Huss
787e75b797 Add resolver opt-in for new feature resolver. 2020-04-19 08:45:18 -07:00
Eric Huss
4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Eric Huss
4367ec4d11 Use Path methods instead of fs::metadata. 2020-04-16 22:00:22 -07:00