mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Set HEAD to correct default branch (#1929)
Sets the HEAD for new Git repositories to the default branch (this is 'main' for the default configuration). This change led to errors in unit tests, that depended on the 'master' branch. Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -36,13 +34,12 @@ import sonia.scm.store.ConfigurationStoreFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@@ -112,4 +109,21 @@ public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
|
||||
File path = repositoryHandler.getDirectory(repository.getId());
|
||||
assertEquals(repoPath.toString() + File.separator + RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSetHeadToDefaultRepository() {
|
||||
GitRepositoryHandler repositoryHandler = new GitRepositoryHandler(factory,
|
||||
scheduler, locationResolver, gitWorkingCopyFactory, null);
|
||||
|
||||
GitConfig config = new GitConfig();
|
||||
config.setDefaultBranch("other");
|
||||
|
||||
repositoryHandler.setConfig(config);
|
||||
|
||||
File nativeRepoDirectory = initRepository();
|
||||
|
||||
repositoryHandler.create(repository);
|
||||
|
||||
assertThat(new File(nativeRepoDirectory, "HEAD")).hasContent("ref: refs/heads/other");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
|
||||
|
||||
ChangesetPagingResult changesets = createCommand().getChangesets(new LogCommandRequest());
|
||||
|
||||
assertEquals("master", changesets.getBranchName());
|
||||
assertEquals("main", changesets.getBranchName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user