Skip to content

Commit 8183c31

Browse files
committed
chore: fix target in generated hg ignore file
1 parent 4a3c588 commit 8183c31

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

Diff for: src/cargo/ops/cargo_new.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
742742
// Using the push method with multiple arguments ensures that the entries
743743
// for all mutually-incompatible VCS in terms of syntax are in sync.
744744
let mut ignore = IgnoreList::new();
745-
ignore.push("/target", "^target/", "target");
745+
ignore.push("/target", "^target$", "target");
746746
if !opts.bin {
747747
ignore.push("/Cargo.lock", "^Cargo.lock$", "Cargo.lock");
748748
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
^target/
1+
^target$
22
^Cargo.lock$

Diff for: tests/testsuite/init/simple_hg/out/.hgignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
^target/
1+
^target$
22
^Cargo.lock$

Diff for: tests/testsuite/init/simple_hg_ignore_exists/out/.hgignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
# Added by cargo
44

5-
^target/
5+
^target$
66
^Cargo.lock$

Diff for: tests/testsuite/new.rs

+17
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,23 @@ fn simple_git() {
100100
cargo_process("build").cwd(&paths::root().join("foo")).run();
101101
}
102102

103+
#[cargo_test(requires_hg)]
104+
fn simple_hg() {
105+
cargo_process("new --lib foo --edition 2015 --vcs hg").run();
106+
107+
assert!(paths::root().is_dir());
108+
assert!(paths::root().join("foo/Cargo.toml").is_file());
109+
assert!(paths::root().join("foo/src/lib.rs").is_file());
110+
assert!(paths::root().join("foo/.hg").is_dir());
111+
assert!(paths::root().join("foo/.hgignore").is_file());
112+
113+
let fp = paths::root().join("foo/.hgignore");
114+
let contents = fs::read_to_string(&fp).unwrap();
115+
assert_eq!(contents, "^target$\n^Cargo.lock$\n",);
116+
117+
cargo_process("build").cwd(&paths::root().join("foo")).run();
118+
}
119+
103120
#[cargo_test]
104121
fn no_argument() {
105122
cargo_process("new")

0 commit comments

Comments
 (0)