Skip to content

Commit 1683cd5

Browse files
committed
Refactor create_empty_config to create_default_config
1 parent 40c5139 commit 1683cd5

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/testsuite/new.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ use cargo_test_support::paths;
55
use std::env;
66
use std::fs::{self, File};
77

8-
fn create_empty_gitconfig() {
8+
fn create_default_gitconfig() {
99
// This helps on Windows where libgit2 is very aggressive in attempting to
1010
// find a git config file.
1111
let gitconfig = paths::home().join(".gitconfig");
1212
File::create(gitconfig).unwrap();
13+
14+
// If we're running this under a user account that has a different default branch set up
15+
// then tests that assume the default branch is master will fail. We set the default branch
16+
// to master explicitly so that tests that rely on this behavior still pass.
17+
fs::write(
18+
paths::home().join(".gitconfig"),
19+
r#"
20+
[init]
21+
defaultBranch = master
22+
"#,
23+
)
24+
.unwrap();
1325
}
1426

1527
#[cargo_test]
@@ -471,19 +483,7 @@ or change the name in Cargo.toml with:
471483
#[cargo_test]
472484
fn git_default_branch() {
473485
// Check for init.defaultBranch support.
474-
create_empty_gitconfig();
475-
476-
// If we're running this under a user account that has a different default branch set up
477-
// this test will fail. We avoid that setting the defaultBranch and then ensuring that
478-
// the changed setting is respected.
479-
fs::write(
480-
paths::home().join(".gitconfig"),
481-
r#"
482-
[init]
483-
defaultBranch = master
484-
"#,
485-
)
486-
.unwrap();
486+
create_default_gitconfig();
487487

488488
cargo_process("new foo").run();
489489
let repo = git2::Repository::open(paths::root().join("foo")).unwrap();

0 commit comments

Comments
 (0)