Commit graph

16984 commits

Author SHA1 Message Date
bors a5b31ebafa Auto merge of #13592 - Byron:gix-for-list-files-git, r=arlosi
Use `gitoxide` for `list_files_git`

Related to #10150.

### Tasks

* [x] update `gix` to v0.60
* [x] assure this is tested (currently only git-tests run with `git2` and `gitoxide`)
* [x] allow `list_files_git` to use `gitoxide` if it is enabled as feature.
* [x] use dirwalk iterator
* [x] use new release of `gix` with necessary updates

### Review Notes

As this PR has come a long way, I decided to keep a few of the steps leading up to the final state, showing the PR's evolution in the hope it helps the review.

* Would it be better to simply use `gitoxide` for this without a switch? I don't think
  it will cause more trouble than `git2`, and if there is an issue I will fix it with priority.
* In one test, the walk resolves a symlink to a submodule to individual files, including the `.git/*` folder contained in the submodule which is ignored by the walk, i.e. `submodule/*` does not contain it, but `submodule-link/*` does. This is fixed in the gitoxide version, and the `git2` version.
* I noticed that symlinks are resolved for packaging *and* are allowed to point to anywhere, even outside of package root. I left it, but felt that maybe this should be reconsidered.

### Remarks

* I love the test-suite! It's incredibly exhaustive to the point where it uncovers shortcomings in `gitoxide`, which I greatly appreciate.
* I also love `git2` as it's API for many things leads to pretty idiomatic code, and sometimes I really have to work to match it. The example here is the initial `dirwalk()` method which requires a delegate as it doesn't just collect into a `Vec` like `git2` does (for good reason). Turning that into an iterator via `dirwalk_iter()` makes it far more usable, and will definitely be good for performance as the dirwalk work is offloaded into its own thread.
2024-03-24 20:01:45 +00:00
bors 77506e5739 Auto merge of #13632 - Muscraft:fix-lints-z-flag, r=ehuss
fix: Warn on -Zlints

When the `[lints]` table was stabilized in #12648, it appears that making `-Zlints` into a warning when specified was missed, this PR fixes that.
2024-03-23 20:14:02 +00:00
Scott Schafer c006a307f7
fix: Warn on -Zlints 2024-03-23 13:53:14 -06:00
bors 61855e72a2 Auto merge of #13621 - Muscraft:linting-system, r=weihanglo
feat: Add a basic linting system

This PR adds a basic linting system, the first step towards [User control over cargo warnings](https://github.com/rust-lang/cargo/issues/12235). To demonstrate the system, a lint for #12826 is added. It supports controlling cargo lints via the `[lints.cargo]` table. Lints can be controlled either by a group or individually.

This is meant to lay down some fundamental infrastructure for the whole linting system and is not meant to be fully featured. Over time, features will be added that will help us reach a much more solid state.
2024-03-23 18:39:37 +00:00
Scott Schafer 307c7f825c
feat: Add a basic linting system 2024-03-23 10:26:02 -06:00
Scott Schafer abf0953292
feat: Add -Zcargo-lints 2024-03-23 10:24:50 -06:00
bors 1728ac594a Auto merge of #13631 - weihanglo:deprecate, r=ehuss
docs: remove untrue TODO for `native_dirs`

`native_dirs` is still in use.
2024-03-23 14:57:21 +00:00
Weihang Lo 1195206581
docs: remove untrue TODO for native_dirs
`native_dirs` is still in use.

See <https://github.com/rust-lang/cargo/pull/6194>
2024-03-23 10:36:40 -04:00
Sebastian Thiel 91781609a5
Assure top-level refspecs and tailing '/' for target prefix
Top-level pathspecs are needed to assure they are not affected by
the CWD. The trailing `/` in `'target` is needed to assure excluded
items are in a folder, and that only entries in that folder are extracted
from the index.
2024-03-23 08:52:12 +01:00
Sebastian Thiel dbf1b6affd
Simplify pathspec generation in list_files_gix
Co-authored-by: Arlo Siemsen <arkixml@gmail.com>
2024-03-23 08:41:27 +01:00
bors 7ff7e34260 Auto merge of #13627 - Muscraft:rename-lint-table-tests, r=epage
refactor(testsuite): Rename lints to lints_table

In preparation for a linting system for cargo, we need a place to put the tests for new lints. Since they would be UI tests, it would make sense to place them in `tests/testsuite/lints/<lint name>`, but tests for `[lints]` are in `tests/testsuite/lints.rs`. To get around this, I am renaming `lints.rs` to `lints_table.rs` so they do not get confused.
2024-03-22 17:40:06 +00:00
Scott Schafer 31c3052524
refactor(testsuite): Rename lints to lints_table 2024-03-22 11:33:58 -06:00
Sebastian Thiel ac68aa1c7c
Don't call .ok() before unwrap_or()
It's not necessary, and adds noise.
2024-03-22 07:24:06 +01:00
bors 8bcecfeed4 Auto merge of #13618 - ehuss:always-rebuild-unit-graph, r=epage
Fix debuginfo strip when using `--target`

This fixes an issue where automatic `strip` of debuginfo added in https://github.com/rust-lang/cargo/pull/13257 wasn't working when the `--target` flag was used.

The problem is that the adjustment code was only running in the optimization pass that is done when `--target` is *not* specified.

The solution is to just always run the unit graph rebuild. I believe it should be safe to do so, since the adjustments it makes should be conditional on just the scenarios that matter when `--target` is not specified. The downside is that this might be a small performance hit when `--target` is used. Trying to avoid that I think would be quite challenging.

Fixes #13617
2024-03-21 21:37:26 +00:00
bors b8b7fa5cd1 Auto merge of #13619 - epage:fold, r=Muscraft
refactor(toml): Push diagnostic complexity on annotate-snippets
2024-03-21 21:05:16 +00:00
Ed Page 69bbb2c1ae refactor(toml): Push diagnostic complex on annotate-snippets 2024-03-21 15:51:32 -05:00
Eric Huss e0e000e1e5 Fix debuginfo strip when using --target 2024-03-21 13:39:45 -07:00
bors c3ad639bb9 Auto merge of #13614 - ehuss:fix-cdn-publish, r=weihanglo
Fix publish script due to crates.io CDN change

Now that crates.io goes directly to the CDN, this has changed the HTTP response code when a crate is not found (from 404 to 403). This updates the publish script to handle more error codes to assume something isn't published. This also updates it to go directly to the endpoint instead of through the crates.io redirect.
2024-03-21 16:33:49 +00:00
Eric Huss 97d896fe52 Fix publish script due to crates.io CDN change 2024-03-21 09:32:05 -07:00
bors d2fbe57b81 Auto merge of #13613 - weihanglo:empty-alias, r=epage
fix(alias): dont panic when resolving an empty alias
2024-03-21 12:56:31 +00:00
Sebastian Thiel 8375cf40ee
assure user and system configuration for .gitignore/exclude files is picked up 2024-03-21 07:07:41 +01:00
Weihang Lo 46214f3c79
fix(alias): dont panic when resolving an empty alias 2024-03-21 00:44:18 -04:00
Weihang Lo 352d8bbe8e
test(alias): panic if alias is empty
This demonstrate the current bad behavior
2024-03-21 00:41:19 -04:00
Sebastian Thiel acef08407b
add custom feature toggle for gitoxide usage in list_files() 2024-03-20 22:11:27 +01:00
bors f0ae765191 Auto merge of #13609 - Muscraft:update-annotate-snippets, r=epage
Update annotate snippets

This updates `annotate-snippets` to `0.11.0`, which introduces the new builder API as well as a few rendering fixes.
2024-03-20 21:08:00 +00:00
bors 5b776ec880 Auto merge of #13610 - weihanglo:refactor-vendor, r=epage
refactor(vendor): tiny not important refactors
2024-03-20 19:49:11 +00:00
Weihang Lo 9f96d7b937
refactor: use a dense pattern matching for str 2024-03-20 15:38:25 -04:00
Weihang Lo 75712e1e30
refactor: reuse Package::root() instead 2024-03-20 14:18:05 -04:00
Scott Schafer f983e2028c
feat: Set term_width for Renderer 2024-03-20 11:01:54 -06:00
Scott Schafer 96bbaa11bf
chore: Update annotate-snippets 2024-03-20 10:42:10 -06:00
bors 266a5ef5ea Auto merge of #13561 - epage:msrv-report, r=weihanglo
feat: Report some dependency changes on any command

### What does this PR try to resolve?

The goal is to help users be informed when they are held back by either MSRV or semver.

Fixes #13539

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

### Additional information
2024-03-20 00:55:52 +00:00
bors d438c80c45 Auto merge of #13603 - epage:toml3, r=weihanglo
refactor(toml): Expose surce/spans for VirtualManifests

### What does this PR try to resolve?

This is a follow up to #13593, expanding support from `Manifest` to `VirtualManifest` as well.

This also does other clean up along the way in preparation for making a more explicit `resolve_toml` phase.

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

### Additional information
2024-03-19 16:11:22 +00:00
bors ecb89a1a4e Auto merge of #13606 - dvdhrm:pr/initlib, r=weihanglo
cargo/init: avoid target.name assignments if possible

Make `cargo init` skip `target.name` assignments if the default value is suitable.

Currently, all paths of `cargo init` will set target-names to the package-name, ensuring that a suitable target-name is set. This is required for all targets but libraries. Unfortunately, library-names have more restrictions than other targets. For example, creating a library with dashes will lead to errors:

    mkdir foo-bar
    cd foo-bar
    touch foo-bar.rs
    cargo init --lib

Fortunately, target-names for libraries are inferred from the package-name. Hence, by omitting the target-name, a valid configuration will be produced.

Instead of adjusting `SourceFileInformation::target_name` to use `Option<String>`, this commit strips the field completely, since all callers set it to the package-name.

Fixes: #11259
2024-03-19 15:39:48 +00:00
Ed Page 627217aa62 docs: Fix original_toml doc comments 2024-03-19 10:18:41 -05:00
bors 3e7852bb65 Auto merge of #13602 - mrobinson:fix-minor-grammar-error, r=weihanglo
chore: Fix minor grammar nit in command-line help

This change fixes a *very* minor grammar mistake. "Require" used in this way is
typically followed by the infinitive. In addition, since "up-to-date" is used
an adjective now it should be hyphenated.

See https://www.merriam-webster.com/dictionary/up-to-date

### Testing

I have run `cargo test` with `CFG_DISABLE_CROSS_TESTS=1` as well as `cargo
build-man` to regenerate the man pages.

Fixes #13601.
2024-03-19 15:04:32 +00:00
David Rheinsberg b673c1010f cargo/init: avoid target.name assignments if possible
Make `cargo init` skip `target.name` assignments if the default value is
suitable.

Currently, all paths of `cargo init` will set target-names to the
package-name, ensuring that a suitable target-name is set. This is
required for all targets but libraries. Unfortunately, library-names
have more restrictions than other targets. For example, creating a
library with dashes will lead to errors:

    mkdir foo-bar
    cd foo-bar
    touch foo-bar.rs
    cargo init --lib

Fortunately, target-names for libraries are inferred from the
package-name. Hence, by omitting the target-name, a valid configuration
will be produced.

Instead of adjusting `SourceFileInformation::target_name` to use
`Option<String>`, this commit strips the field completely, since all
callers set it to the package-name.

Signed-off-by: David Rheinsberg <david@readahead.eu>
2024-03-19 11:07:41 +01:00
bors 1e70a10a25 Auto merge of #13604 - weihanglo:version-bump, r=epage
Bump to 0.80.0; update changelog

[rendered](https://github.com/weihanglo/cargo/blob/version-bump/CHANGELOG.md)
2024-03-18 21:34:35 +00:00
Weihang Lo d85644ea55
Update changelog for 1.79.0 2024-03-18 17:29:31 -04:00
Weihang Lo 6706ee9c35
Update changelog for 1.78.0 2024-03-18 17:29:31 -04:00
Ed Page 00d542f58a refactor(features): Remove redundant is_local
Its the caller's job to decide whether the warning is relevant
2024-03-18 11:41:06 -05:00
Weihang Lo e6dccf946f
Bump to 0.80.0 2024-03-18 11:44:35 -04:00
Sebastian Thiel 363d2da187
address PR review (see details)
* remove renovate group as it's not needed anymore
* repository discovery will open with isolation
2024-03-18 15:35:50 +01:00
Martin Robinson 8fa25ba41d chore: Fix minor grammar nit in command-line help
A *very* minor grammar correction. "Require" used in this way is
typically followed by the infinitive.
2024-03-18 14:32:28 +01:00
Sebastian Thiel 9bf91497db
Use the new dirwalk iterator for comparable ergonomics 2024-03-18 10:17:47 +01:00
Sebastian Thiel 5312586492
Assure the extra-logic in dirwalks applies to index files as well
This is the case for the git2 implementation naturally, but as
`gitoxide` doesn't yet have a dirwalk iterator, it's much
less intuitive here.
2024-03-18 10:12:51 +01:00
Sebastian Thiel a710d459af
assure repositories are always walked into to avoid .git folders.
With a traditional walk, `.git` will be picked up, and so will be
ignored directories. This commit also doesn't give submodules special
treatment - instead it just tries to open directories as repositories,
or walks them if that fails.
2024-03-18 10:07:04 +01:00
Sebastian Thiel 9115545053
implement list_files_gix to be used when gitoxide is enabled. 2024-03-18 10:06:13 +01:00
Sebastian Thiel a989423650
upgrade gix to v0.60
It contains the feature required to get a directory traversal.
2024-03-18 09:39:10 +01:00
Ed Page 9882ab3260 refactor(toml): Proces unused keys on Manifest 2024-03-16 19:45:34 -05:00
bors 69726309bf Auto merge of #12783 - dvdhrm:pr/libname2, r=ehuss
cargo: prevent dashes in lib.name

The TOML parser of Cargo currently refuses `lib.name` entries that contain dashes. Unfortunately, it uses the package-name as default if no explicit `lib.name` entry is specified. This package-name, however, can contain dashes.

Cargo documentation states that the package name is converted first, yet this was never implemented by the code-base.

Fix this inconsistency and convert the package name to a suitable crate-name first.

This fixes #12780. It is an alternative to #12640.
2024-03-16 20:50:35 +00:00