Skip to content

Commit 9ef7490

Browse files
committed
Ignore Cargo.lock for libs in cargo-new
The lockfile should only be checked in for bins, not libs. Closes rust-lang#304
1 parent 07b9c70 commit 9ef7490

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cargo/ops/cargo_new.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ fn mk(path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> {
3232

3333
if opts.git {
3434
try!(git!("init", path));
35-
try!(File::create(&path.join(".gitignore")).write(b"/target\n"));
35+
let mut gitignore = "/target\n".to_string();
36+
if !opts.bin {
37+
gitignore.push_str("/Cargo.lock\n");
38+
}
39+
try!(File::create(&path.join(".gitignore")).write(gitignore.as_bytes()));
3640
} else {
3741
try!(fs::mkdir(path, io::UserRWX));
3842
}

0 commit comments

Comments
 (0)