Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid duplicates in ignore files #6521

Merged

Conversation

starsheriff
Copy link
Contributor

@starsheriff starsheriff commented Jan 4, 2019

Hi,
here is my first PR for cargo. It's my take on #6377 with some minor refactoring included, mainly to avoid keeping the two different types of ignore file entries (gitignore and hg) in sync.) Basically, the contents of a ignore file are now read if the file exists and filtered out. To filter out I would propose to just comment the entries that cargo would add out, in that way it is nice to see which duplicates were found and more important what cargo usually adds. In that way, a user can modify his ignore file and be sure that he can keep everything that cargo would add.

A new ignore file will look like this:

/target
**/*.rs.bk
Cargo.lock",

An existing ignore file will be modified like this:

/target
/some/other/path

#Added by cargo
#
#already existing elements are commented out

#/target
**/*.rs.bk
Cargo.lock

Fixes #6377

existing ignore files are now checked for duplicates. If the file
already contains an entry it is commented out in the section added by
cargo.

fixes rust-lang#6377
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dwijnand (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@dwijnand
Copy link
Member

dwijnand commented Jan 6, 2019

LGTM! Thank you for also fixing ignoring Cargo.lock in new binary crates on mercurial (glob:Cargo.lock)! I'm not sure if that had ever been filed, but it's good to have it fixed.

I'm going to land this if any other maintainer has any feedback please feel free to share and we can address it.

@bors: r+

@bors
Copy link
Collaborator

bors commented Jan 6, 2019

📌 Commit 99a23c0 has been approved by dwijnand

@bors
Copy link
Collaborator

bors commented Jan 6, 2019

⌛ Testing commit 99a23c0 with merge 5b0dfb2...

bors added a commit that referenced this pull request Jan 6, 2019
…iles, r=dwijnand

avoid duplicates in ignore files

Hi,
here is my first PR for cargo. It's my take on #6377 with some minor refactoring included, mainly to avoid keeping the two different types of ignore file entries (gitignore and hg) in sync.) Basically, the contents of a ignore file are now read if the file exists and filtered out. To filter out I would propose to just comment the entries that cargo would add out, in that way it is nice to see which duplicates were found and more important _what cargo usually adds_. In that way, a user can modify his ignore file and be sure that he can keep everything that cargo would add.

A new ignore file will look like this:
```
/target
**/*.rs.bk
Cargo.lock",
```

An existing ignore file will be modified like this:
```
/target
/some/other/path

#Added by cargo
#
#already existing elements are commented out

#/target
**/*.rs.bk
Cargo.lock
```

Fixes #6377
@bors
Copy link
Collaborator

bors commented Jan 6, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: dwijnand
Pushing 5b0dfb2 to master...

@bors bors merged commit 99a23c0 into rust-lang:master Jan 6, 2019
bors added a commit to rust-lang/rust that referenced this pull request Jan 14, 2019
Update cargo

13 commits in 34320d212dca8cd27d06ce93c16c6151f46fcf2e..2b4a5f1f0bb6e13759e88ea9512527b0beba154f
2019-01-03 19:12:38 +0000 to 2019-01-12 04:13:12 +0000
- Add test for publish with [patch] + cleanup. (rust-lang/cargo#6544)
- Fix clippy warning (rust-lang/cargo#6546)
- Revert "Workaround by using yesterday's nightly" (rust-lang/cargo#6540)
- Adding feature-flags to `cargo publish` and `cargo package` (rust-lang/cargo#6453)
- Fix the Travis CI badge (rust-lang/cargo#6530)
- Add helpful text for Windows exceptions like Unix (rust-lang/cargo#6532)
- Report fix bugs to Rust instead of Cargo (rust-lang/cargo#6531)
- --{example,bin,bench,test} with no argument now lists all available targets (rust-lang/cargo#6505)
- Rebuild on mid build file modification (rust-lang/cargo#6484)
- Derive Clone for TomlDependency (rust-lang/cargo#6527)
- publish: rework the crates.io detection logic. (rust-lang/cargo#6525)
- avoid duplicates in ignore files (rust-lang/cargo#6521)
- Rustflags in metadata (rust-lang/cargo#6503)

r? @alexcrichton
@ehuss ehuss added this to the 1.33.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cargo init creates duplicates in .gitignore
5 participants