Fix initialization bug if master set as default branch

Fixes issue https://github.com/scm-manager/scm-manager/issues/1467
where initialization fails when master is set as default branch.
This commit is contained in:
René Pfeuffer
2020-12-07 13:34:10 +01:00
committed by Sebastian Sdorra
parent f1934735fa
commit e62a598aa2
3 changed files with 27 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@SuppressWarnings("java:S5976") // using parameterized tests in this class is not useful because we would miss the descriptions
public class GitModifyCommand_withEmptyRepositoryTest extends GitModifyCommandTestBase {
@Test
@@ -70,6 +71,18 @@ public class GitModifyCommand_withEmptyRepositoryTest extends GitModifyCommandTe
}
}
@Test
public void shouldCreateCommitOnMasterIfSetExplicitly() throws IOException, GitAPIException {
createContext().getGlobalConfig().setDefaultBranch("master");
executeModifyCommand();
try (Git git = new Git(createContext().open())) {
List<Ref> branches = git.branchList().call();
assertThat(branches).extracting("name").containsExactly("refs/heads/master");
}
}
@Test
public void shouldCreateCommitWithConfiguredDefaultBranch() throws IOException, GitAPIException {
createContext().getGlobalConfig().setDefaultBranch("main");