mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-04 05:39:11 +01:00
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:
committed by
Sebastian Sdorra
parent
f1934735fa
commit
e62a598aa2
@@ -113,14 +113,20 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
|
||||
String branch = StringUtils.isNotBlank(request.getBranch()) ? request.getBranch() : context.getGlobalConfig().getDefaultBranch();
|
||||
if (StringUtils.isNotBlank(branch)) {
|
||||
try {
|
||||
getClone().checkout().setName(branch).setCreateBranch(true).call();
|
||||
setBranchInConfig(branch);
|
||||
} catch (GitAPIException e) {
|
||||
createBranchIfNotThere(branch);
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new InternalRepositoryException(repository, "could not create default branch for initial commit", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createBranchIfNotThere(String branch) throws IOException, GitAPIException {
|
||||
if (!branch.equals(getClone().getRepository().getBranch())) {
|
||||
getClone().checkout().setName(branch).setCreateBranch(true).call();
|
||||
setBranchInConfig(branch);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBranchInConfig(String branch) {
|
||||
ConfigurationStore<GitRepositoryConfig> store = gitRepositoryConfigStoreProvider
|
||||
.get(repository);
|
||||
|
||||
Reference in New Issue
Block a user