Commit graph

2978 commits

Author SHA1 Message Date
bors 0460192d1a Auto merge of #11337 - weihanglo:compression-ratio, r=ehuss
Aware of compression ratio for unpack size limit
2022-11-29 19:10:00 +00:00
Caleb Fletcher f54cd332e2 Add test for rustdoc map usage with sparse alternative registries 2022-11-29 19:28:03 +11:00
bors a2ea66bea6 Auto merge of #11400 - hi-rustin:rustin-patch-fix-error, r=epage
Add error message when `cargo fix` on an empty repo

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11380

Add error message when `cargo fix` on an empty repo.

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

- [x] unit test

```sh
set -eux

cargo +nightly new repro
cd repro
echo "fn main() { let _ = 0.clone(); }" > src/main.rs
cargo fix
```
2022-11-28 13:01:15 +00:00
bors a004f94c48 Auto merge of #11387 - arlosi:sparse-url, r=weihanglo
Store the sparse+ prefix in the SourceId for sparse registries

#11209 added a new `SourceKind::SparseRegistry` and removed the `sparse+` prefix from the URLs stored in the `SourceId`.

The removal of the `sparse+` prefix from the URLs in the `SourceId` has led to several bugs, since registry URLs no longer round-trip through a `SourceId`. The most recent one I found was that the example configuration generated by `cargo vendor` did not include the `sparse+` prefix. Any place that calls the `.url()` method on a `SourceId` potentially has this bug.

This change puts the `sparse+` prefix back in the URL stored in the `SourceId`, but keeps the new `SourceKind::SparseRegistry`.

A test is added for doing `cargo vendor` on an alternative registry using the sparse protocol.
2022-11-27 16:00:17 +00:00
hi-rustin 21b2fe98a4 Fix fix_in_existing_repo_weird_ignore broken test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin 3189dc3b06 Include untracked files
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin 25f7d4b09a Remove new_repo_without_add_and_commit
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin 89b8a8bb10 Suppress error with --allow-dirty and add a test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
bors 79fe7573b0 Auto merge of #11401 - adam248:patch-1, r=ehuss
add newline char to `cargo install .` error message for easier reading.

I just noticed the `cargo install .` error message was not formatted very nicely.

Just added a newline char to make it cleaner.

Thanks
2022-11-25 13:34:10 +00:00
bors de56c1251b Auto merge of #10343 - willcrichton:example-analyzer, r=weihanglo
Change rustdoc-scrape-examples to be a target-level configuration

This PR addresses issues raised in rust-lang/cargo#9525. Specifically:
1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc.
2. It moves the `arg` from `-Z rustdoc-scrape-examples={arg}` into a target-level configuration that can be added to Cargo.toml.

The added test `scrape_examples_configure_target` shows a concrete example. In short, examples will be default scraped from Example and Lib targets. Then the user can enable or disable scraping like so:

```toml
[lib]
doc-scrape-examples = false

[[test]]
name = "my_test"
doc-scrape-examples = true
```
2022-11-25 06:58:20 +00:00
Weihang Lo d5cac16d07
temporarily disable test lto::test_profile
- CI failing
  - <https://github.com/rust-lang/cargo/actions/runs/3542820690/jobs/5948722067>
  - <https://github.com/rust-lang/cargo/actions/runs/3535399031/jobs/5933377592>
- Tracking in <https://github.com/rust-lang/rust/issues/104852>
- Discussing in <https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/windows.20gnu.20LTO.20CI.20error>
2022-11-25 01:04:49 +00:00
Will Crichton 183425f0bc Add test to confirm #10876 is fixed. 2022-11-23 09:35:59 -06:00
Will Crichton c26ed6357f Add doc comments to explain scrape-examples feature 2022-11-22 15:19:18 -06:00
bors 995f5efcc2 Auto merge of #11186 - hi-rustin:rustin-patch-add-suggestion, r=epage
Add suggestions when `cargo add` multiple packages

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11173
Add suggestions when `cargo add` multiple packages. See https://github.com/rust-lang/cargo/issues/11173#issuecomment-1265692022

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

- [x] unit test
2022-11-22 14:10:58 +00:00
Adam Butler 1b7e256413 fixed typo causing broken cargo install . test case 2022-11-22 14:14:29 +09:30
Adam Butler db0d3f9de1
fixed cargo fmt error regarding unknown escape char. 2022-11-22 13:24:59 +09:30
Adam Butler c5836e97ba
fixed broken error made by newline char in cargo install . error message 2022-11-22 13:19:05 +09:30
hi-rustin a3eb31fab4 Fix typo try use -> try to use
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 18:14:17 +08:00
bors 63fdd75bde Auto merge of #11377 - hi-rustin:rustin-patch-warning-tree, r=weihanglo
Add warning when `cargo tree -i <spec>` can not find packages

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11315

Add warning when `cargo tree -i <spec>` can not find packages.

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

Please run the unit test.
2022-11-20 08:52:04 +00:00
hi-rustin c5eb61823c Remove the --all-features tip
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 16:39:00 +08:00
bors 43689d353a Auto merge of #11194 - cassaundra:cargo-remove-gc, r=epage
Clean profile, patch, and replace in cargo remove

### What does this PR try to resolve?

This PR is part of the continued work on cargo remove (#11099, see deferred work).

After a successful removal of a dependency, clean up the profile, patch, and replace sections to remove all references to it.

**Note** the GC process was expanded to clean up not just references to the dependencies just removed, but also references of all dependencies. This was because there's not an easy way to determine which dependencies correspond to the given TOML keys, without either 1) figuring that out before the removal (therefore having to predict the behavior), or 2) returning that information from the remove function (somewhat unorthodox for an op).

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

Verify that the implementation makes sense and that the tests are sufficient.
2022-11-19 02:46:46 +00:00
Cassaundra Smith 299252c78d Clean profile, patch, and replace in cargo remove
After a successful removal of a dependency, clean up the profile, patch, and
replace sections to remove all references to the dependency.
2022-11-18 09:33:37 -06:00
Arlo Siemsen 7cd613773d Fix several tests that are waiting 60 seconds for publishing to time out 2022-11-17 15:54:24 -06:00
Arlo Siemsen 1da79baf54 Store the sparse+ prefix in the URL for sparse registries 2022-11-17 14:25:47 -06:00
Arlo Siemsen 9827412fee Implement RFC 3139: alternative registry authentication support 2022-11-16 14:36:19 -06:00
Will Crichton b325a8d5d5 Fix complex_reverse_dependencies test 2022-11-16 09:18:37 -08:00
Will Crichton 39e6737de7 Change rustdoc-scrape-examples to be a target-level configuration 2022-11-16 09:18:33 -08:00
Arlo Siemsen 24bf873c83 Fix cargo install --index when used with registry.default 2022-11-15 11:28:29 -06:00
hi-rustin a4f89eab03 Add warning when cargo tree -i <spec> can not find packages
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-15 09:41:39 +08:00
xxchan a858cc6c4a improve error message for cargo add/remove 2022-11-14 20:32:09 +01:00
RyanAD f1fed1b294 keep empty test directory 2022-11-12 18:43:47 -07:00
RyanAD 730e8ca46d make call to paths::join_paths and warn if path contains invalid chars 2022-11-12 18:43:46 -07:00
RyanAD 82a92a203c Warn if project path contains an invalid PATH env character 2022-11-12 18:43:35 -07:00
bors a3dfea71ca Auto merge of #11321 - FrankYang0529:fix-11311, r=epage
fix: return non UTF-8 error message

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

### Test Steps

1. Create a new empty Git repository
2. Create a `.gitignore` that is not valid UTF-8, for instance `printf '\xFF\xFE' > .gitignore`
3. `cargo init`
2022-11-11 03:50:47 +00:00
Frank Yang b98c534d57
fix: return non UTF-8 error message
Signed-off-by: Frank Yang <yangpoan@gmail.com>
2022-11-10 23:49:08 +08:00
bors 9865dde6d0 Auto merge of #11353 - weihanglo:issue/10527, r=epage
Propagate change of artifact bin dep to its parent fingerprint
2022-11-10 02:30:46 +00:00
Weihang Lo 347523e163
fix(fingerprint): include bin target if it is also an artifact dep 2022-11-09 17:44:17 +00:00
Weihang Lo 58e86d4d94
test(bindeps): recompile when bin target is also artifact dep
This records the WRONG behaviour, which parent fingerpint cannot detect
change of a dependency if it is a bin target and also a artifact dep.
2022-11-09 16:29:15 +00:00
Arlo Siemsen 90c6b5854d Fix waiting for publishing to complete when publishing to a sparse registry 2022-11-08 18:14:52 -06:00
Weihang Lo e295a1056e
test(features2): test to prevent regressing of optional host deps of dep 2022-11-07 17:42:05 +00:00
Weihang Lo de7cd31eac
aware of compression ratio for unpack size limit 2022-11-04 18:40:44 +00:00
bors 68e9d6c17b Auto merge of #11327 - epage:wait, r=ehuss
test(publish): Cover more wait-for-publish cases

These came from trying to guess what cases are causing problems in #11314.  Unfortunately, can't reproduce it so far but figured it'd be good to keep these around.
2022-11-04 00:04:29 +00:00
Weihang Lo 5fe27327c3
Revert "Auto merge of #11183 - weihanglo:issue/10526, r=ehuss"
This reverts commit d4c38af120, reversing
changes made to 92d8826ed4.
2022-11-03 15:08:30 +00:00
Ed Page d87966b466 test(publish): Require extra waits 2022-11-02 16:42:14 -05:00
Ed Page 6998fb3896 test(publish): Verify updating existing entries works 2022-11-02 10:39:21 -05:00
Ed Page 4dc2e405e6 test(publish): Don't pre-publish 2022-11-02 10:37:28 -05:00
bors 352175f810 Auto merge of #11285 - jonhoo:cargo-env, r=weihanglo
Make cargo forward pre-existing CARGO if set

Currently, Cargo will always set `$CARGO` to point to what it detects its own path to be (using `std::env::current_exe`). Unfortunately, this runs into trouble when Cargo is used as a library, or when `current_exe` is not actually the binary itself (e.g., when invoked through Valgrind or `ld.so`), since `$CARGO` will not point at something that can be used as `cargo`. This, in turn, means that users can't currently rely on `$CARGO` to do the right thing, and will sometimes have to invoke `cargo` directly from `$PATH` instead, which may not reflect the `cargo` that's currently in use.

This patch makes Cargo re-use the existing value of `$CARGO` if it's already set in the environment. For Cargo subcommands, this will mean that the initial invocation of `cargo` in `cargo foo` will set `$CARGO`, and then Cargo-as-a-library inside of `cargo-foo` will inherit that (correct) value instead of overwriting it with the incorrect value `cargo-foo`. For other execution environments that do not have `cargo` in their call stack, it gives them the opportunity to set a working value for `$CARGO`.

One note about the implementation of this is that the test suite now needs to override `$CARGO` explicitly so that the _user's_ `$CARGO` does not interfere with the contents of the tests. It _could_ remove `$CARGO` instead, but overriding it seemed less error-prone.

Fixes #10119.
Fixes #10113.
2022-11-02 12:38:30 +00:00
Cassaundra Smith 38b23d5c68
Clean up workspace dependencies after cargo remove 2022-11-01 12:08:16 -07:00
bors 9e71316fcb Auto merge of #10621 - LovecraftianHorror:more-precise-artifact-cleanup, r=weihanglo
Only remove fingerprints and build script artifacts of the requested package

Fixes #10069

This is my first PR to cargo. Let me know if you want me to add tests, or if there are any other changes you would like to see :)

This PR changes the globs used to remove fingerprints and build artifacts when running `cargo clean -p <pkid>`. The glob used was `<package_name>-*` which would match artifacts for packages that are prefixed by `<package_name>-` (e.g. `cargo clean -p sqlx` would also remove artifacts for `sqlx-{core,macros,etc.}`). This problem is not seen with other artifacts since those use the crate name instead of package name which normalize hyphens to underscores.

The changes follow the naive approach mentioned in #10069 where some basic string manipulation is done to strip off the last hyphen, hash, and potential extension to get the original package name which can be used to determine if the artifact is actually for the desired package. This means that this **does not** handle trying to resolve the package to determine the artifacts, so it still ignores the url and version that may be passed in the pkgid
2022-11-01 11:49:13 +00:00
bors 37cad5bd7f Auto merge of #11308 - ehuss:clean-tmp-libgit2, r=weihanglo
Clean stale git temp files

### What does this PR try to resolve?

When cargo is interrupted while libgit2 is indexing the pack file, it will leave behind a temp file that never gets deleted. These files can be very large. This checks for these stale temp files and deletes them.

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

There is a simulated test here. To test with the actual behavior:

1. Run `CARGO_HOME=chome cargo fetch`
2. While it is "resolving deltas", hit Ctrl-C.
3. Notice that there is a 200MB file in `chome/registry/index/github.com-1ecc6299db9ec823/.git/objects/pack/`
4. Do that several times if you want, each time adds another 200MB file.
5. Build this PR: `cargo b -r`
6. Run `CARGO_HOME=chome CARGO_LOG=cargo::sources::git::utils=debug ./target/release/cargo fetch`
7. Notice that it deletes the `pack_git2_*` files.
2022-11-01 09:21:14 +00:00