Commit graph

5118 commits

Author SHA1 Message Date
Sebastian Thiel 3bd08d934b
Move helper functions to the bottom for consistency; fix name 2023-05-02 18:57:42 +02:00
Sebastian Thiel 2aaebcbcaa
Only fetch single object in shallow mode for compatibility 2023-04-29 14:29:11 +02:00
Sebastian Thiel d4b8fc68ab
Allow fetching a single object, shallow or not.
Doing so seems cleaner as there should be no logical difference between
shallow or not-shallow when fetching. We want a specific object, and should
get it with the refspec. `git` will assure we see all objects we need,
handling shallow-ness for us.

Note that one test needed adjustments due to the different mechanism used
when fetching local repositories, requiring more changes to properly 'break'
the submodule repo when `gitoxide` is used.
2023-04-29 12:21:45 +02:00
Sebastian Thiel 8b3508cad7
Move all tests for shallow fetching into their own module
Note that those which test both with and without shallow still go
into the shallow module.
2023-04-29 09:52:08 +02:00
Sebastian Thiel 2f45cb54fa
Assure that git-dependencies will get the correct storage, without ever unshallowing them.
This is an improvement over the previous version which would use unshallowing that effectively
makes a shallow repo *not* shallow.

Furthermore, we will now only fetch a single commit, each time we fetch, which should be faster
for the server as well as for the client.

We also make it possible to fetch individual commits that would be specified via Cargo.lock.
2023-04-27 18:49:59 +02:00
Sebastian Thiel 4b93f095c8
Various improvements to address the PR review.
https://github.com/rust-lang/cargo/pull/11840#pullrequestreview-1383844802
2023-04-27 14:19:01 +02:00
Sebastian Thiel 38d92dd9a8
place shallow git dependencies into a different directory.
That way, we avoid any danger with older cargo's not being able
to handle such a repository correctly.
2023-04-27 14:18:27 +02:00
Sebastian Thiel d4af571686
name the shallow registry differently
A couple of test expectations are adjusted accordingly.

Is this desirable behaviour? Unfortunately, there is no alternative
as adding shallow to an existing index most definitely breaks backwards
compatibility.
2023-04-27 14:18:26 +02:00
Sebastian Thiel c7ff94fce8
Enable shallow clones and fetches for registry and git dependencies.
The implementation hinges on passing information about the kind of clone
and fetch to the `fetch()` method, which then configures the fetch accordingly.

Note that it doesn't differentiate between initial clones and fetches as
the shallow-ness of the repository is maintained nonetheless.
2023-04-27 14:18:22 +02:00
cassaundra 5554889f88
Include rust-version in publish request
crates.io reads rust-version from the tarball directly, but we can include it in
the publish request for the sake of consistency for third-party registries.
2023-04-26 11:59:29 -07:00
Kyle Matsuda 90c7d3b9b8 update the publish_with_missing_readme test with new warning 2023-04-25 12:27:39 -06:00
Kyle Matsuda 27e95997ce failing tests on empty readme and license-path fields 2023-04-25 12:27:39 -06:00
Weihang Lo 00484fe00a
fix: apply [env] to target info discovery rustc 2023-04-24 20:30:44 +01:00
Weihang Lo e1c7ce8903
test: [env] isn't applied to target info discovery rustc 2023-04-24 20:28:20 +01:00
bors b5177c6d46 Auto merge of #12001 - hi-rustin:rustin-patch-dep-empty, r=weihanglo
Improve error message for empty dep
2023-04-24 09:20:41 +00:00
bors 77069b43f0 Auto merge of #11958 - jyn514:named-debuginfo, r=Muscraft
Allow named debuginfo options in Cargo.toml
2023-04-22 15:08:08 +00:00
bors 738c699342 Auto merge of #11997 - hi-rustin:rustin-patch-dep-message, r=weihanglo
Better error message when getting an empty dep table
2023-04-20 09:16:30 +00:00
hi-rustin af0cd9fc5a Improve error message for empty dep
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-20 09:32:24 +08:00
hi-rustin e0276cae19 Update error message to not start with capital letters
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-20 09:16:45 +08:00
jyn a982bccfe8 add more debuginfo tests 2023-04-19 20:01:04 -05:00
hi-rustin 4d401bd0b9 Add test for empty dep table error
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-20 08:49:30 +08:00
Eric Huss 6fa758e83c Fix flaky not_found_permutations test. 2023-04-14 08:01:34 -07:00
bors b0742b2145 Auto merge of #11882 - hi-rustin:rustin-patch-clippy-fix, r=weihanglo
Correct the bug report for `cargo clippy --fix`
2023-04-14 07:05:37 +00:00
hi-rustin 08169fd015 Add rustc_shim_for_cargo_fix and wrapped_clippy_driver to reuse code
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-14 11:23:41 +08:00
hi-rustin 47f6e2ddc9 Add broken_clippy_fixes_backed_out
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-04-14 10:46:53 +08:00
bors 84b7041fd2 Auto merge of #11950 - ehuss:stabilize-logout, r=epage
Stabilize `cargo logout`

This stabilizes the `cargo logout` command.

Closes #11910
Closes #11884
2023-04-13 20:08:40 +00:00
jyn 8a9db7a020 Address review comments
- Update the documentation and doc-comments
- Improve the error message for parsing Cargo.toml
2023-04-12 12:05:14 -05:00
Eric Huss a70c108961 Stabilize cargo logout 2023-04-12 09:56:43 -07:00
Eric Huss c00a633bd6 Don't display headers in spurious warning message.
The headers can significantly contribute to noise in the output,
drowning out the rest of the output. Most investigation will likely be
focused on the case where cargo completely fails to download, so this
only shows the full detail in the final error message.
2023-04-12 09:38:53 -07:00
Eric Huss 4702fa3ad3 Include the IP address in HTTP errors. 2023-04-12 09:38:53 -07:00
Eric Huss c7c9b8f32b Show some HTTP headers in error messages. 2023-04-12 09:38:52 -07:00
bors 96f8d6ced8 Auto merge of #11949 - ehuss:logout-default, r=epage
Use registry.default for login/logout

This changes `cargo login` and `cargo logout` to use the registry configured at `registry.default` as the registry instead of crates.io. For `cargo login`, this was an unintentional regression from #6466. The documentation has always stated that it will use the default registry.

This makes the command more in line with other registry-involving commands. There are still some inconsistencies.

These commands use the default if not specified:

* `cargo init`
* `cargo new`
* `cargo owner`
* `cargo search`
* `cargo yank`
* `cargo publish` uses the default, but will also look at the `publish` field `Cargo.toml` and use that if the registry is not specified.

These commands would always use crates.io if `--registry` is not specified:

* `cargo login`
* `cargo logout`
* `cargo install`

I'm a bit uncertain how to proceed, since this is technically a breaking change particularly if someone has scripted it. I suspect that the number of users that use `registry.default` is very small, and those that script `cargo login` are even smaller, and thus the intersection is probably small or nonexistent. However, there is some risk here.
2023-04-12 13:45:57 +00:00
Eric Huss 3da2b3c67b Mark -C as unstable 2023-04-11 19:46:05 -07:00
Joshua Nelson d861dcf792 Allow named debuginfo options in Cargo.toml
Rustc supports these since rust-lang/rust#109808. It's technically
possible to set a named debuginfo level through `RUSTFLAGS`, but in
practice cargo always passes its own opinion of what the debuginfo level
is, so allow it to be configured through cargo too.
2023-04-11 15:06:02 -05:00
Eric Huss a9e0b505d6 Update auth error message to specify args for cargo login. 2023-04-10 10:20:21 -07:00
bors c429784fd5 Auto merge of #11951 - ehuss:check-token-tab, r=hi-rustin
Fix credential token format validation.

The existing validation incorrectly excluded tab because of a missing backslash. This updates to add the backslash.

This also rewords the comments. I found the current comments to be a little confusing.

This also extends the test to verify more valid inputs.

cc #11600
2023-04-10 04:02:43 +00:00
Eric Huss 35f5862979 Validate token on publish. 2023-04-09 12:15:40 -07:00
Eric Huss 57264ed433 Fix credential token format validation. 2023-04-09 11:53:46 -07:00
Eric Huss 117eb4b33f Use registry.default for login/logout 2023-04-09 09:30:36 -07:00
Eric Huss 0e13f667c8 Add tests for registry.default for login/logout 2023-04-09 09:22:28 -07:00
Eric Huss 91d39bc742 Share the check_token function between login and logout tests. 2023-04-09 09:11:22 -07:00
Arlo Siemsen a888c94052 Stop using UncanonicalizedIter for QueryKind::Exact 2023-04-05 15:52:01 -05:00
Eric Huss 1ee340c0a7 Don't query permutations of the path prefix. 2023-04-04 18:49:42 -07:00
Arlo Siemsen a1cba8fe49 Fix Cargo warning about unused sparse configuration key
When doing a credential lookup, Cargo deserializes the registry configuration and detects the
registries.crates-io.protocol key as unused and issues a warning.

This fixes the issue by adding the field to the struct
2023-04-03 11:27:11 -05:00
Eric Huss 78970bd4a8 Update git2 2023-04-02 15:37:53 -07:00
bors 0e474cfd7b Auto merge of #11881 - ehuss:http-retry, r=epage
Add delays to network retries.

This adds a delay to network retries to help guard against short-lived transient errors.

The overview of how this works is: Requests that fail are placed into a queue with a timestamp of when they should be retried. The download code then checks for any requests that need to be retried, and re-injects them back into curl.

Care must be taken in the download loops to track which requests are currently in flight *plus* which requests are waiting to be retried.

This also adds jitter to the retry times so that multiple failed requests don't all flood the server when they are retried. This is a very primitive form of jitter which suffers from clumping, but I think it should be fine.

The max number of retries is raised to 3 in order to bring the total retry time to around 10 seconds. This is intended to address Cloudfront's default negative TTL of 10 seconds. The retry schedule looks like 0.5seconds ± 1 second, then 3.5 seconds then 6.5 seconds, for a total of 10.5 to 11.5 seconds.  If the user configures additional retries, each attempt afterwards has a max delay of 10 seconds.

The retry times are currently not user-configurable. This could potentially be added in the future, but I don't think is particularly necessary for now.

There is an unfortunate amount of duplication between the crate download and HTTP index code. I think in the near future we should work on consolidating that code. That might be challenging, since their use patterns are different, but I think it is feasible.
2023-03-31 23:15:58 +00:00
Eric Huss 6bd1209a55 Add delays to network retries. 2023-03-31 14:04:48 -07:00
Eric Huss f393f96d7f Add a note to cargo logout that it does not revoke the token. 2023-03-31 08:03:51 -07:00
Eric Huss 5860cd23a2 Disable test_profile test on windows-gnu 2023-03-30 19:18:10 -07:00
Ed Page 6feea34f8a chore: Upgrade to clap v4.2
Tests in `master` are currently failing because its building with clap
v4.2 but the tests have snapshots from v4.1
2023-03-28 05:00:49 -05:00