Skip to content

Commit a74e148

Browse files
committed
Auto merge of #4017 - pietroalbini:ensure-test-git-index-branch, r=Turbo87
Ensure the HEAD for test indexes is "master" Different versions of git2 in different systems use a different name for the HEAD branch they create, switching between "master" and "main". This causes test failures when they pick "main", as the rest of crates.io assumes the branch is named "master". This commit changes the HEAD name during tests to always be "master", allowing the test suite to work everywhere without breakages. Refactoring the application not to care about the branch name will be done in a future commit, this just focuses on unbreaking the test suite.
2 parents b0d8bf7 + 77aec72 commit a74e148

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/tests/git.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ pub fn init() {
2424
fs::create_dir_all(root().parent().unwrap()).unwrap();
2525
});
2626

27-
let bare = git2::Repository::init_bare(&bare()).unwrap();
27+
let bare = git2::Repository::init_opts(
28+
&bare(),
29+
git2::RepositoryInitOptions::new()
30+
.bare(true)
31+
.initial_head("master"),
32+
)
33+
.unwrap();
2834
let mut config = bare.config().unwrap();
2935
config.set_str("user.name", "name").unwrap();
3036
config.set_str("user.email", "email").unwrap();

0 commit comments

Comments
 (0)