Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/mercurial_autodetect/out/.hgignore
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_hg/out/.hgignore
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_hg_ignore_exists/out/.hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Added by cargo

^target/
^target$
^Cargo.lock$
17 changes: 17 additions & 0 deletions tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ fn simple_git() {
cargo_process("build").cwd(&paths::root().join("foo")).run();
}

#[cargo_test(requires_hg)]
fn simple_hg() {
cargo_process("new --lib foo --edition 2015 --vcs hg").run();

assert!(paths::root().is_dir());
assert!(paths::root().join("foo/Cargo.toml").is_file());
assert!(paths::root().join("foo/src/lib.rs").is_file());
assert!(paths::root().join("foo/.hg").is_dir());
assert!(paths::root().join("foo/.hgignore").is_file());

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

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

#[cargo_test]
fn no_argument() {
cargo_process("new")
Expand Down