Skip to content

Commit

Permalink
chore: fix target dir ignore in generated gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Mar 15, 2023
1 parent 4a3c588 commit fdd35e4
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
// Using the push method with multiple arguments ensures that the entries
// for all mutually-incompatible VCS in terms of syntax are in sync.
let mut ignore = IgnoreList::new();
ignore.push("/target", "^target/", "target");
ignore.push("/target/", "^target/", "target");
if !opts.bin {
ignore.push("/Cargo.lock", "^Cargo.lock$", "Cargo.lock");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/init/auto_git/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
/Cargo.lock
2 changes: 1 addition & 1 deletion tests/testsuite/init/explicit_bin_with_git/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
/target/
2 changes: 1 addition & 1 deletion tests/testsuite/init/git_autodetect/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Added by cargo

/target
/target/
/Cargo.lock
2 changes: 1 addition & 1 deletion tests/testsuite/init/inferred_bin_with_git/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
/target/
2 changes: 1 addition & 1 deletion tests/testsuite/init/inferred_lib_with_git/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
/Cargo.lock
2 changes: 1 addition & 1 deletion tests/testsuite/init/pijul_autodetect/out/.ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
/Cargo.lock
2 changes: 1 addition & 1 deletion tests/testsuite/init/simple_git/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
/Cargo.lock
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/target
/target/
**/some.file
4 changes: 2 additions & 2 deletions tests/testsuite/init/simple_git_ignore_exists/out/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/target
/target/
**/some.file

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

#/target
#/target/
/Cargo.lock
2 changes: 1 addition & 1 deletion tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn simple_git() {

let fp = paths::root().join("foo/.gitignore");
let contents = fs::read_to_string(&fp).unwrap();
assert_eq!(contents, "/target\n/Cargo.lock\n",);
assert_eq!(contents, "/target/\n/Cargo.lock\n",);

cargo_process("build").cwd(&paths::root().join("foo")).run();
}
Expand Down

0 comments on commit fdd35e4

Please sign in to comment.