Commit graph

17563 commits

Author SHA1 Message Date
Ed Page eafc743c0d chore: Update to snapbox 0.6
We needed to tweak the redactions because snapbox no longer normalizes
slashes on redactions unless the data type is a `PathBuf`.
2024-05-27 21:26:20 -05:00
Ed Page 0bd034cd06 refactor(test): Split up calls by type 2024-05-27 21:24:43 -05:00
Ed Page 4a6f25c112 refactor: Resolve snapbox deprecations 2024-05-27 10:28:13 -05:00
Ed Page 602f2f2e21 chore: Upgrade to snapbox 0.5.14 2024-05-24 14:55:47 -05:00
Ed Page fc733032b3 chore: Bump cargo-credential 2024-05-24 14:55:42 -05:00
bors a8d72c675e Auto merge of #13956 - linyihai:missing-fields, r=weihanglo
Improve error description when deserializing partial field struct

### What does this PR try to resolve?

Fixes #13688

### How should we test and review this PR?
one commit add test, one commit fixed and update the test.

### Additional information
2024-05-24 03:34:17 +00:00
Lin Yihai e05d930e16 fix: Add more context when 'missing feild' 2024-05-24 11:29:46 +08:00
bors 9f7a7157ff Auto merge of #13910 - hi-rustin:rustin-patch-symlink, r=weihanglo
fix: remove symlink dir on Windows
2024-05-23 13:41:32 +00:00
hi-rustin 40ff7be1ad
fix: remove symlink on Windows
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-05-23 21:18:33 +08:00
bors 3830c0ccc2 Auto merge of #13957 - iawia002:docs, r=weihanglo
Fix wrong type of rustc-flags in documentation

When I tried to add some custom configuration according to the documentation in https://doc.rust-lang.org/cargo/reference/config.html#configuration-format, I encountered the following error:

```
error: expected a string, but found a array for `rustc-flags` in /xxx/.cargo/config.toml
```

I believe the type of `rustc-flags` should be a string:

95b921ba59/src/doc/src/reference/config.md?plain=1#L1243-L1253
2024-05-23 12:45:51 +00:00
Xinzhao Xu 63e84611e5 Fix wrong type of rustc-flags in documentation 2024-05-23 17:01:34 +08:00
Lin Yihai 48742e009c test: Add 'missing field' test 2024-05-23 15:27:52 +08:00
bors 95b921ba59 Auto merge of #13951 - epage:trace, r=ehuss
Add more high level traces

This accounts for more time when running rustc (which turns out to be a significant amount of time).

I'm less sure about the start/wait calls but I'm seeing very different results from different builds of `cargo` and some have some large amounts of unaccounted time that I want to dig into (and callgrind and and samply haven't helped).
2024-05-22 18:25:05 +00:00
Ed Page 8cfccebc31 Add more high level traces
This accounts for more time when running rustc (which turns out to be a
significant amount of time).

I'm less sure about the start/wait calls but I'm seeing very different
results from different builds of `cargo` and some have some large
amounts of unaccounted time that I want to dig into (and callgrind and
and samply haven't helped).
2024-05-22 11:54:57 -05:00
bors 145b225e20 Auto merge of #13948 - Byron:upgrade-gix, r=epage
upgrade gix from 0.62 to 0.63

This is a bugfix release with various improvements, some of which relevant to safety when checking out (possibly freshly cloned) repositories.

See https://github.com/Byron/gitoxide/security/advisories/GHSA-7w47-3wg8-547c and https://github.com/Byron/gitoxide/security/advisories/GHSA-49jc-r788-3fc9 (might not be published yet as it was waiting for feedback at the time of writing).
2024-05-22 15:30:23 +00:00
bors 048e804d0a Auto merge of #13939 - tbu-:pr_template_no_usize, r=weihanglo
Use `i32` rather than `usize` as "default integer" in library template

`usize` was renamed from `uint` in order to convey that it's not the "default integer type". Guide new users to use `i32` instead of `usize`.
2024-05-22 14:30:29 +00:00
Tobias Bucher a29742a396 Use u64 rather than usize as "default integer" in library template
`usize` was renamed from `uint` in order to convey that it's not the
"default integer type". Guide new users to use integers with specific
bit width instead of `usize`.
2024-05-22 16:11:00 +02:00
Sebastian Thiel 81a59b01ec
upgrade gix from 0.62 to 0.63
This is a bugfix release with various improvements, some of which relevant
to safety when checking out (possibly freshly cloned) repositories.

See https://github.com/Byron/gitoxide/security/advisories/GHSA-7w47-3wg8-547c
and https://github.com/Byron/gitoxide/security/advisories/GHSA-49jc-r788-3fc9
2024-05-22 15:17:45 +02:00
bors 99075f2a47 Auto merge of #13946 - iliana:13555-object-not-found, r=weihanglo
fetch specific commits even if the github fast path fails

### What does this PR try to resolve?

This PR fixes #13555, which describes a regression from 1.64.0 to 1.65.0 where the inability to fetch commit information from api.github.com (the "GitHub fast path") silently changes Cargo's behavior.

Cargo can fetch a specific Git commit from a remote without having to fetch all refs. Prior to #10807, this functionality required a repository hosted on github.com and providing the full commit hash (usually available from the Cargo.lock); after that change, any revision (including abbreviated revisions) that could be resolved by GitHub's API could be fetched directly. However, this logic requires the "GitHub fast path", which was not intended to be robust, to successfully return the resolved commit hash; if a client is currently rate-limited by api.github.com (very common in CI and shared cloud / corporate environments) this fails and Cargo falls back to fetching all refs.

Usually this is not noticeable. However, GitHub allows fetching commits that are related to the repository but not actually part of any of its refs, including commits pushed to a fork. This results in the same command working fine in some environments where api.github.com is accessible, and not working in other environments that are rate-limited, which is very confusing and difficult to debug.

This change adds another branch to cover the regression case: if we are going through the GitHub fast path with a full commit hash, return early indicating that we need to fetch it. (Previously: ~~when the GitHub fast path was unsuccessful, the user is not using the unstable shallow clone options, and we have a full commit hash and expect to be able to fetch it directly because we know it's a github.com repository.~~)

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

I have been testing this PR by temporarily adding a `0.0.0.0 api.github.com` entry to my `/etc/hosts`, which causes the GitHub fast path to always fail, then running:

```
target/release/cargo install --git https://github.com/haha-business/unstable-test-repo.git --rev c9040898c9183ddbb9402dcbf749ed06d6ea90ad
```

This refers to [a particular commit on a fork of the repo](c9040898c9) which won't be found by the fallback path or current Cargo.

**Note** that you will need to delete `~/.cargo/git/checkouts/unstable-test-repo-*` and `~/.cargo/git/db/unstable-test-repo-*` after a successful run with this change in order to reproduce the broken behavior of the current release.

I am having trouble getting the test suite to run at all on my system so I haven't experimented with writing a specific test for this case, but I probably should.

### Additional information

This uses the same logic as the unstable shallow clone support to detect if the revision is a full commit hash. This is not compatible with SHA-256 commit hashes; `git2::Oid` specifically expects a 40-character hexadecimal string. Given that the change introducing this bug was meant to future-proof SHA-256 support (despite only doing so for GitHub repositories), it might be good to make the logic more explicit within Cargo and allow either 40- or 64-character hex strings.

I wanted to keep this change focused on the regression fix, but in testing, pretty much every Git repository I could think of (including non-forges, like git.kernel.org and some repositories I host on my own infrastructure with cgit) supports fetching directly from a commit, so it would be ideal to eventually relax the GitHub requirement for this functionality. However, it would need some sort of fallback logic because I suspect the HTTP [dumb protocol](https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols) doesn't support commit references, and I haven't researched when this functionality was added to the smart protocol.
2024-05-22 04:54:54 +00:00
iliana etaoin 5d7a06ba0b don't ask github to resolve full commit hashes
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2024-05-21 21:30:52 -07:00
hi-rustin 0e1b115ccd
test: add case for the symlink file
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-05-21 20:16:35 +08:00
hi-rustin 8b0161ede4
test: add a test case for removing symlink dir
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-05-21 20:00:56 +08:00
bors 84dc5dc11a Auto merge of #13938 - ehuss:permissions-warning, r=weihanglo
Fix warning about unused Permissions

This fixes an unused warning about the `Permissions` import on non-unix platforms.
2024-05-20 18:57:08 +00:00
Eric Huss cf7857354f Fix warning about unused Permissions 2024-05-20 11:40:44 -07:00
bors 3bbfe786a1 Auto merge of #13907 - weihanglo:ipv6, r=ehuss
fix: support IPv6-only network for cargo fix
2024-05-20 17:43:31 +00:00
bors bb6e446067 Auto merge of #13927 - cuviper:libsecret-soname, r=weihanglo
Load `libsecret` by its `SONAME`, `libsecret-1.so.0`

The library name `libsecret-1.so` is only found in `-dev` or `-devel` packages on many distros, and it's usually only a symlink. For example, this is what I have on Fedora:

    /usr/lib64/libsecret-1.so -> libsecret-1.so.0
    /usr/lib64/libsecret-1.so.0 -> libsecret-1.so.0.0.0
    /usr/lib64/libsecret-1.so.0.0.0

    $ rpm -qf /usr/lib64/libsecret*
    libsecret-devel-0.21.4-2.fc40.x86_64
    libsecret-0.21.4-2.fc40.x86_64
    libsecret-0.21.4-2.fc40.x86_64

The middle `libsecret-1.so.0` filename matches the actual `SONAME` in the library, which you can see with `readelf -d`, and this is what programs built directly against this library will use. It's a better choice for dynamic loaders too, so devel packages aren't needed.
2024-05-20 16:30:48 +00:00
bors ef60a454f1 Auto merge of #13937 - epage:docs, r=weihanglo
docs(ref): Simplify check-cfg build.rs docs

### What does this PR try to resolve?

After looking over the rust documentation updates, decided to look over Cargo's build.rs documentation.

- Removed link to the blog post as that is not evergreen documentation
- Collapsed down the example to put more emphasis on the more complete example

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

### Additional information
2024-05-20 14:59:24 +00:00
Ed Page a0fb4ac6e7 docs(ref): Link to the more full docs on check-cfg 2024-05-20 09:52:45 -05:00
Ed Page bd744f0919 docs(ref): Integrate link to unexpected_cfgs lint 2024-05-20 09:44:58 -05:00
Ed Page 1162546c8b docs(ref): Flatten the check-cfg structure 2024-05-20 09:03:15 -05:00
Ed Page 88b15d7473 docs(ref): Simplify text for link to check-cfg example 2024-05-20 09:02:16 -05:00
Ed Page 27e067c8d5 docs(ref): Fix typo on check-cfg 2024-05-20 08:59:40 -05:00
Ed Page bea65c71ae docs(ref): Remove blog post link
Blog posts are not evergreen documentation.
2024-05-20 08:58:45 -05:00
bors 2332d7a428 Auto merge of #13935 - Urgau:local-independent-git-test, r=epage
Make `git::use_the_cli` test truly locale independent

### What does this PR try to resolve?

The current `git::use_the_cli` test part the output of Git but that output is locale dependant, making it fail on my non-english system.

Specifically this part of the test is local-dependent:
```
From [..]
 * [new ref] [..] -> origin/HEAD[..]
```

Adding the `LC_ALL=C` env to the cargo invocation solve the issue, making the test locale independent.

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

Trying putting a different `LC_ALL` locale and the test will fail without this PR and will not fail with my PR.
2024-05-20 13:28:53 +00:00
Urgau 8fdac923e8 Make git::use_the_cli test truly locale independent 2024-05-19 19:39:34 +02:00
bors c256d74031 Auto merge of #13929 - ehuss:squelch-unittest-warnings, r=weihanglo
Silence warnings running embedded unittests.

The `util::toml::embedded::test_expand` unittests were printing warnings directly to stderr, circumventing the libtest override. They were displaying ``warning: `package.edition` is unspecified, defaulting to `2021` ``. That warning doesn't look particularly important for those tests, so this changes it to swallow the output.

We may want to have some kind of utility function for generating a GlobalContext for testing purposes that does this, since this is a repeated pattern.
2024-05-19 02:25:57 +00:00
bors 0f685f6198 Auto merge of #13930 - ehuss:squelch-git-output, r=weihanglo
Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git

The test `build_with_symlink_to_path_dependency_with_build_script_in_git` was emitting a large warning block (in my case, about init.defaultBranch) because it was running `git` without filtering its output. It's not clear to me why this test was shelling out to `git` instead of using the built-in test support functions. From what I can tell, this should be exactly equivalent, and silences the warning output.
2024-05-19 01:23:50 +00:00
bors 198ba31be3 Auto merge of #13572 - linyihai:multi-dep-same-name, r=ehuss
Fix:  Make path dependencies with the same name stays locked

### What does this PR try to resolve?
Fixes: https://github.com/rust-lang/cargo/issues/13405

This is a workround based on https://github.com/rust-lang/cargo/issues/13405#issuecomment-1930496807

### How should we test and review this PR?
first commit will pass, second commit fixed it and update test.

### Additional information
2024-05-18 22:12:27 +00:00
bors 986dac36af Auto merge of #13931 - ehuss:standard_lib-no-sysroot, r=weihanglo
Temporarily fix standard_lib tests on linux.

This fixes the standard_lib tests which are broken in the latest nightly. The latest nightly now requires rust-lld to be in the sysroot for x86_64-unknown-linux-gnu. This broke these tests which were trying to verify that the standard library is not required. This temporarily removes this validation, but we should have some way of enforcing it (https://github.com/rust-lang/wg-cargo-std-aware/issues/31).

cc https://github.com/rust-lang/rust/issues/125246
2024-05-18 21:34:38 +00:00
Eric Huss 473e770cdd Temporarily fix standard_lib tests on linux. 2024-05-18 14:00:06 -07:00
Eric Huss 2e9dcdbdf5 Fix warning output in build_with_symlink_to_path_dependency_with_build_script_in_git 2024-05-18 13:19:53 -07:00
Eric Huss 369f5dea13 Silence warnings running embedded unittests. 2024-05-18 12:59:43 -07:00
Lin Yihai ab927171ce fix: Make path dependencies with the same name stays locked 2024-05-18 12:45:11 -07:00
Lin Yihai 5c1b6313fa test: Add a test about patched re-export 2024-05-18 12:43:48 -07:00
Josh Stone 4ee7b9c260 Load libsecret by its SONAME, libsecret-1.so.0
The library name `libsecret-1.so` is only found in `-dev` or `-devel`
packages on many distros, and it's usually only a symlink. For example,
this is what I have on Fedora:

    /usr/lib64/libsecret-1.so -> libsecret-1.so.0
    /usr/lib64/libsecret-1.so.0 -> libsecret-1.so.0.0.0
    /usr/lib64/libsecret-1.so.0.0.0

    $ rpm -qf /usr/lib64/libsecret*
    libsecret-devel-0.21.4-2.fc40.x86_64
    libsecret-0.21.4-2.fc40.x86_64
    libsecret-0.21.4-2.fc40.x86_64

The middle `libsecret-1.so.0` filename matches the actual `SONAME` in
the library, which you can see with `readelf -d`, and this is what
programs built directly against this library will use. It's a better
choice for dynamic loaders too, so devel packages aren't needed.
2024-05-17 16:05:30 -07:00
bors 0de7f2ec6c Auto merge of #13913 - Urgau:check-cfg-lints-sub-config, r=epage
Add special `check-cfg` lint config for the `unexpected_cfgs` lint

### What does this PR try to resolve?

This PR adds a special `check-cfg` lint config for the `unexpected_cfgs` lint, as it was decided by T-cargo (in today's meeting).

The goal of this lint config is to provide a simple and cost-less alternative to the build-script `cargo::rustc-check-cfg` instruction.

```toml
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(foo, values("bar"))'] }
```

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

I recommand reviewing commit by commit; and looking at all the new tests added in `check_cfg.rs`, I tried making them as exhaustive as I could, many of them are very similar to their non-config counterpart.

### Additional information

I didn't add *(actually removed from the 1st version of this PR)* the possibility to omit the `level` field if `check-cfg` is specified, https://github.com/rust-lang/cargo/pull/13913#discussion_r1600609229.

Regarding the implementation, I tried making it is as straight forward as possible, nothing over-engineered or complex.

r? `@epage` (or `@weihanglo` maybe)
2024-05-17 16:54:54 +00:00
bors 2b8804475d Auto merge of #13924 - weihanglo:registry, r=epage
refactor: more comments and variable rename
2024-05-17 15:05:37 +00:00
Weihang Lo 9d69986331
docs: tweak comments for patches 2024-05-17 10:27:25 -04:00
Weihang Lo 8e051a692b
refactor: rename and type-alias to clarify patch arguments 2024-05-17 00:29:02 -04:00
Weihang Lo 4e393497fa
refactor: unindent two levels for registry query function 2024-05-16 22:46:28 -04:00