15324 Commits

Author SHA1 Message Date
Weihang Lo
4830653705
chore(triagebot): auto label when PR review state changes 2023-10-19 09:43:07 -04:00
bors
680a0f9d24 Auto merge of #12838 - epage:add, r=weihanglo
fix(add): Preserve more comments

### What does this PR try to resolve?

This was fixed in killercup/cargo-edit#725 and I forgot to carry it over to here.

I kept in some auto-formatting because there is little to preserve until the TOML 1.1 spec is out which will allow mult-line inline-tables which means there might be comments interspersed.  We'll see which comes first, `cargo fmt` support for `Cargo.toml` or the 1.1 spec.

Fixes #10850

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

First commit adds a test demonstrating the problem.  The second makes a lot of noise that the third cleans up, so its a mixed bag as to which commit to look at.

### Additional information
2023-10-19 02:31:46 +00:00
bors
5225467af0 Auto merge of #12853 - weihanglo:cname-warning, r=ehuss
ci: big ⚠️ to ensure the CNAME file is always there

### What does this PR try to resolve?

A request from <https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/doc.2Ecrates.2Eio.20CNAME.20missing>

The CNAME file is for GitHub to redirect requests to the custom domain.
Missing this may entail security hazard and domain takeover.
See <https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/managing-a-custom-domain-for-your-github-pages-site#securing-your-custom-domain>
2023-10-19 01:40:25 +00:00
Weihang Lo
ec9c5b0b43
ci: big ⚠️ to ensure the CNAME file is always there 2023-10-18 21:31:10 -04:00
bors
5fab767241 Auto merge of #12850 - weihanglo:dashdashbench, r=epage
docs(cargo-bench): `--bench` is passed in unconditionally to bench harnesses
2023-10-18 21:25:14 +00:00
bors
0820fa1933 Auto merge of #12846 - rust-lang:revert-12834-pr/contrib, r=epage
docs(contrib): generate redirection HTML pages in CI

### What does this PR try to resolve?

#12834 wiped out the old content of all link redirections. From my understanding it relies on the existing gh-pages hosting those files.

This PR pulls out the [`generate.py`](cff4125983/generate.py) from older `gh-pages` branch, and run it during the CI deploy job.

### How to review

It succeeds on my fork <https://github.com/weihanglo/cargo/tree/gh-pages> ([CI log](https://github.com/weihanglo/cargo/actions/runs/6564128361/job/17829881499#step:4:1)).

I don't think `.lock` or [`.nojekyll`](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/) is needed. If it causes problem, we can add them back.
2023-10-18 19:44:34 +00:00
Weihang Lo
ff376df716
docs(cargo-bench): --bench is passed in unconditionally to bench harnesses 2023-10-18 15:40:12 -04:00
bors
9b994157b3 Auto merge of #12842 - weihanglo:remove-notice, r=epage
docs: remove review capacity notice

The Cargo project is in a better state than it was when maintainers added this notice. I believe it's time to take it down, as maintainers have got more time on it, and more people are willing to contribute to the project constantly.

Note that this doesn't mean Cargo start accepting arbitrary pull requests or features. The reviewers are still a small handful of people. The guideline never change — issue, discuss, then pull request.
2023-10-18 18:41:08 +00:00
bors
141667875e Auto merge of #12841 - epage:help, r=weihanglo
fix(help):Clarify install's positional

### What does this PR try to resolve?

- That a version is accepted
- That you are selecting from the source a package which led to part of
  the confusion in #4830

I wonder if we should rename our `CRATE` value names to `PKG`/`PACKAGE`

While doing this, I decided to fix the inconsistency in how we handle value names in help.

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

### Additional information
2023-10-18 17:45:08 +00:00
Weihang Lo
6f3e30b773
docs: remove review capacity notice 2023-10-18 13:24:09 -04:00
Weihang Lo
4f0016d457
ci: generate link redirections when publising contrib doc 2023-10-18 12:59:06 -04:00
bors
16629e6a5a Auto merge of #12845 - Urgau:check-cfg-adjust-for-rustc, r=epage
Adjust `-Zcheck-cfg` for new rustc syntax and behavior

https://github.com/rust-lang/rust/pull/111072 introduced a new syntax for `rustc` `--check-cfg` argument. This PR adjust cargo `-Zcheck-cfg` for new that new syntax and behavior.

This PR removes all the `-Zcheck-cfg` options (`features`, `names`, `values`, `output`), as they don't make much sense now since with the new `rustc` behavior: `features`, `names` and `values` are all combine together and the `output` option was only here because the other were.

Now the new behavior from cargo is to always pass one `--check-cfg` argument to rustc for the `feature`s which implicitly enables well known names and values.
2023-10-18 16:29:03 +00:00
Urgau
2f79f15018 Update Cargo reference for new -Zcheck-cfg behavior and syntax 2023-10-18 18:11:54 +02:00
Weihang Lo
208922f1fc
ci: pull out generate.py from gh-pages branch 2023-10-18 12:08:28 -04:00
bors
67271fd7a9 Auto merge of #12806 - epage:replace, r=Eh2406
fix(replace): Partial-version spec support

### What does this PR try to resolve?

#12614 changed package ID specs to allow fields in the version number to be optional.  This earliest branch with this change is `rust-1.74.0` (beta).  While `@Eh2406` was investigating version metadata issues in #12772, problems with the partial version change were found
- `replace`s that specify version metadata were ignored **(fixed with this PR)**
  - This also extends out to any other place a PackageIDSpec may show up, like `cargo check -p <name>`@<spec>``
  - We explicitly kept the same semantics of version requirements that pre-releases require opt-in.  If nothing else, this gives us more room to change semantics in the future if we ever fix the semantics for pre-release.
- `replace`s that don't specify version metadata when the `Cargo.lock` contained a version metadata, it would previously be ignored (with a warning) but now match **(unchanged with this PR)**
  - When the version metadata in `Cargo.lock` differed from the overriding `Cargo.toml`, cargo would panic **(now an error in this PR)**

With this PR, we are acknowledging that we changed behavior in taking ignored replaces (because of differences with version metadata) and applying them.  Seeing as version metadata is relatively rare, replaces are relatively rare, and differences in it for registries is unsupported, the impact seems very small.

The questions before us are
- Do we revert #12614 in `master` and `rust-1.74.0` or merge this PR into `master`
- If we merge this PR into `master`, do we cherry-pick this into `rust-1.74.0` or revert #12614, giving ourselves more time to find problems

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

The initial commit adds tests that pass as of #12614.  Prior to #12614, these tests would have warned that the `replace` was unused and failed because `bar::bar` didn't exist.  Each commit then changes the behavior (or not) and updates the corresponding test.

### Additional information
2023-10-18 15:42:23 +00:00
Urgau
4b93690c9d Adjust -Zcheck-cfg for new rustc syntax and behavior
This commit removes all the -Zcheck-cfg options (features, names,
values, output), as they don't make much sense now since features, names
and values are all combine together for upstream rustc and the output
option was only here because the other were.

Now the new behavior from cargo is to always pass one `--check-cfg`
argument to rustc for the `feature`s which implicitly enables well known
names and values.
2023-10-18 15:10:25 +02:00
bors
a275529de2 Auto merge of #12829 - Nilstrieb:verbosebuildrs, r=weihanglo
Print environment variables for build script executions with `-vv`

### What does this PR try to resolve?

When debugging complicated builds (I was trying to figure out how  `cargo-miri` cross-compiles compiler_builtins without needing a C cross compiler), it's useful to see all the environment variables passed to the build script.

This is also consistent with other commands.

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

I tested it locally by creating a small crate with an empty `build.rs` and building it. Additionally, a test is included.
2023-10-18 02:52:14 +00:00
bors
709ac17f62 Auto merge of #12840 - epage:suggest, r=hi-rustin
fix(cli): Suggest cargo-search on bad commands

This is a low-tech solution alternative to the options proposed in #4682
- Search `[[bin]]`s within all packages in the registry (which aren't tracked atm), suggesting to `cargo install` what is found
- Check if `cargo-<cmd>` is in the registry, suggesting `cargo install if it is

By suggesting `cargo search`, we are giving them a tool so they can verify if the package is what they want (a `cargo info` would help as a next step).

Is is needed?
- New users might not know of `cargo search` but they can search on crates.io
- New users might not be aware of the `cargo-<cmd>` naming pattern

Seems like this can still offer some benefit.

Fixes #4682
2023-10-18 01:51:13 +00:00
Ed Page
5f0596941f fix(help): Clarify install's positional
- That a version is accepted
- That you are selecting from the source a package which led to part of
  the confusion in #4830

I wonder if we should rename our `CRATE` value names to `PKG`/`PACKAGE`
2023-10-17 16:48:15 -05:00
Ed Page
99f917a67e fix(help): Consistently use SCREAMING_CASE for value names
- We have some positional value names that are SCREAMING_CASE and some
  that aren't
- All of the value names for our flags are already SCREAMING_CASE
2023-10-17 16:47:44 -05:00
bors
4cf7937fd5 Auto merge of #12836 - epage:fmt, r=weihanglo
docs(contrib): Policy on manifest editing

Based on https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Automatic.20edits.20to.20.60Cargo.2Ctoml.60
2023-10-17 20:03:08 +00:00
Ed Page
ec3ed20d2a fix(cli): Suggest cargo-search on bad commands
This is a low-tech solution alternative to the options proposed in #4682
- Search `[[bin]]`s within all packages in the registry (which aren't
  tracked atm), suggesting to `cargo install` what is found
- Check if `cargo-<cmd>` is in the registry, suggesting `cargo install
  if it is

By suggesting `cargo search`, we are giving them a tool so they can
verify if the package is what they want (a `cargo info` would help as a
next step).

Is is needed?
- New users might not know of `cargo search` but they can search on
  crates.io
- New users might not be aware of the `cargo-<cmd>` naming pattern

Seems like this can still offer some benefit

Fixes #4682
2023-10-17 14:46:30 -05:00
bors
f806be2dde Auto merge of #12835 - dvdhrm:pr/contrib-concurrency, r=weihanglo
ci/contrib: use separate concurrency group

Run the contrib workflow in its own concurrency group to avoid multiple runs causing conflicting git pushes.

The contrib workflow pushes to the gh-pages branch, and thus is not safe to be run multiple times in parallel. Given that github-actions can stall workflow runs for quite some time, multiple executions can overtake each other. By using concurrency groups, all workflow runs will wait until previous runs completed.

Given that the workflow uses orphan-branches and forced pushes, conflicting workflows will not fail, but might produce outdated data if they overtake each other.

We explicitly disable cancellation to get better diagnostics and more easily find the first possible run that failed. Since these workflow runs are rather fast, and only run on master, cancellation seems not necessary.
2023-10-17 19:04:23 +00:00
Ed Page
02dd917511 fix(add): Add back in some auto-formatting
This moves the auto-format to the correct place so it takes effect.
2023-10-17 12:48:45 -05:00
Ed Page
99e4847d78 fix(add): Stop auto-formatting content
Huh, overlooked the cargo side when I fixed this in killercup/cargo-edit#725

Fixes #10850
2023-10-17 12:48:08 -05:00
Ed Page
716ae6238f test(add): Check table formatting issues 2023-10-17 12:23:45 -05:00
Ed Page
b5c63f6868 docs(contrib): Policy on manifest editing
Based on https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Automatic.20edits.20to.20.60Cargo.2Ctoml.60
2023-10-17 10:29:18 -05:00
Ed Page
1e34066360 test(replace): Clarify name for remaining new test 2023-10-17 10:09:45 -05:00
Ed Page
7502318a85 fix(replace): Error, rather than assert, on version mismatch 2023-10-17 10:09:45 -05:00
Ed Page
d318ed4c14 fix(spec): Require opt-in for pre-release 2023-10-17 10:09:45 -05:00
Ed Page
0ec3274326 fix(spec): Ensure PackageIdSpec respects version 'build' field 2023-10-17 10:09:41 -05:00
bors
8537dffa1e Auto merge of #12834 - dvdhrm:pr/contrib, r=weihanglo
ci/contrib: do not fail on missing gh-pages

The current contrib deploy-hook fails if there is no `gh-pages` branch. Change the CI order to disregard the old `gh-pages` branch first.

The `contrib` deploy-hook always creates a fresh `gh-pages` commit and pushes it out. However, currently it relies on the old `gh-pages` branch to exist, since it does not ignore errors when pruning it. Fortunately, the code always creates a new orphan branch, since it does not want to keep history for deployments. Therefore, we can simply use:

    `git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named `<branch>`, and override an existing branch if it exists (see `-b` vs `-B`). Hence, there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly specify the remote to push to. We no longer set up branch tracking.

Note that running github-actions in a private fork is quite useful to avoid constantly pushing changes to a PR and triggering notifications. Unfortunately, private forks on github do not automatically clone the gh-pages branch. This PR fixes annoying CI failures when updating the master branch on private forks, since github does not automatically clone the gh-pages branch.
2023-10-17 14:25:13 +00:00
David Rheinsberg
cdc7c1be02 ci/contrib: use separate concurrency group
Run the contrib workflow in its own concurrency group to avoid multiple
runs causing conflicting git pushes.

The contrib workflow pushes to the gh-pages branch, and thus is not safe
to be run multiple times in parallel. Given that github-actions can
stall workflow runs for quite some time, multiple executions can
overtake each other. By using concurrency groups, all workflow runs will
wait until previous runs completed.

We explicitly disable cancellation to get better diagnostics and more
easily find the first possible run that failed. Since these workflow
runs are rather fast, and only run on master, cancellation seems not
necessary.
2023-10-17 16:02:03 +02:00
bors
ff768b45b3 Auto merge of #12823 - calavera:fix_remove_help_typos, r=weihanglo
Clarify flag behavior in `cargo remove --help`

### What does this PR try to resolve?

I noticed what I believe are typos in `cargo rm --help`:

```
Section:
      --dev              Remove as development dependency
      --build            Remove as build dependency
      --target <TARGET>  Remove as dependency from the given target platform
```

This change updates that section with a more appropriate description of those flags.

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

I've updated the relevant test for that help output.

### Additional information

Sorry for not opening an issue about this. I believe it's easy enough to approve it if my assumption is correct.
2023-10-17 12:51:31 +00:00
David Rheinsberg
1d261830a0 ci/contrib: do not fail on missing gh-pages
The current contrib deploy-hook fails if there is no `gh-pages` branch.
Change the CI order to disregard the old `gh-pages` branch first.

The `contrib` deploy-hook always creates a fresh `gh-pages` commit and
pushes it out. However, currently it relies on the old `gh-pages` branch
to exist, since it does not ignore errors when pruning it. Fortunately,
the code always creates a new orphan branch, since it does not want to
keep history for deployments. Therefore, we can simply use:

    `git worktree --orphan -B <branch> <path>`

This will ensure to always create an orphan branch named `<branch>`, and
override an existing branch if it exists (see `-b` vs `-B`). Hence,
there is no need for us to prune the old branch, anymore.

Since we will recreate the branch on every push, we have to explicitly
specify the remote to push to. We no longer set up branch tracking.
2023-10-17 14:28:23 +02:00
bors
8eb8acbb11 Auto merge of #12832 - weihanglo:cargo-login, r=ehuss
doc(cargo-login): mention args after `--` in manpage
2023-10-17 11:55:04 +00:00
David Calavera
8849d25218 Update rm help to be specific about the section.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2023-10-17 11:53:57 +02:00
Weihang Lo
536e0b7688
doc(cargo-login): mention args after -- in manpage 2023-10-16 23:35:50 -04:00
Ed Page
ae068fbf4c test(replace): Show behavior post-#12614
PR #12614
- Changed ignored replaces to not-ignored
- Has bugs in matching replaces
2023-10-16 11:09:27 -05:00
Ed Page
1bf12a5671 test(spec): Cover meta/pre cases for partial versions
We already tested with missing minor/patch
2023-10-16 11:09:27 -05:00
Ed Page
2fc644a7cd test(spec): Make room for more tests 2023-10-16 11:03:35 -05:00
bors
87f4b1ba07 Auto merge of #12830 - weihanglo:compat-notice, r=epage
changelog: add compat notice for `cargo login -- <arg>`
2023-10-16 14:39:46 +00:00
Weihang Lo
edfd9034b7
changelog: add compat notice for cargo login -- <arg> 2023-10-15 16:29:59 -04:00
Nilstrieb
d4044c9d01 Print environment variables for build script executions with -vv
This is consistent with other commands.
2023-10-15 19:50:11 +02:00
bors
c857ebb73a Auto merge of #12827 - tompscanlan:spdx-license-bug, r=weihanglo
update SPDX License info

### What does this PR try to resolve?

fixes #12797
* link to latest license info
* update link for further info to main spdx page

Link to further info was pointing to a 2018 news update, now points to the main spdx page.
2023-10-15 14:15:00 +00:00
Tom Scanlan
eb9e7f2277
update SPDX License info
* link to latest license info
* update link for further info to main spdx page
* Update src/doc/src/reference/manifest.md
* point directly at expression syntax

Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>

update license list
2023-10-15 10:05:50 -04:00
bors
fadb3b1c60 Auto merge of #12822 - hi-rustin:rustin-patch-version, r=weihanglo
Add test for `-V` short argument

Just found it when I randomly jumped into this file :(
2023-10-14 15:46:11 +00:00
hi-rustin
267ae195e3 Add test for -V short argument
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-14 23:16:11 +08:00
bors
f7e7cc2356 Auto merge of #12820 - linyihai:broken-symlink-target, r=weihanglo
add detailed message when target folder path is invalid

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

add more detailed message when target folder path is invalid

# How should we test and review this PR?

Before this PR, if the target folder refer to broken symbolic link like /a/b/c, then run cargo build, the output is:

```
error: Not a directory (os error 20)
```
the detailed error message is missing.

This PR will add the error context for it, the finall output will be
```
cargo build
error: failed to create directory `/root/workspace/playground/target`

Caused by:
  Not a directory (os error 20)
```
2023-10-14 04:43:58 +00:00
Lin Yihai
ceac419776 add detailed message when target folder path is invalid 2023-10-14 11:34:42 +08:00