This commit is contained in:
René Pfeuffer
2020-10-30 13:18:27 +01:00
parent 94b65e0e3a
commit 6195e4a290

View File

@@ -114,19 +114,23 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
if (StringUtils.isNotBlank(branch)) {
try {
getClone().checkout().setName(branch).setCreateBranch(true).call();
ConfigurationStore<GitRepositoryConfig> store = gitRepositoryConfigStoreProvider
.get(repository);
GitRepositoryConfig gitRepositoryConfig = store
.getOptional()
.orElse(new GitRepositoryConfig());
gitRepositoryConfig.setDefaultBranch(branch);
store.set(gitRepositoryConfig);
setBranchInConfig(branch);
} catch (GitAPIException e) {
throw new InternalRepositoryException(repository, "could not create default branch for initial commit", e);
}
}
}
private void setBranchInConfig(String branch) {
ConfigurationStore<GitRepositoryConfig> store = gitRepositoryConfigStoreProvider
.get(repository);
GitRepositoryConfig gitRepositoryConfig = store
.getOptional()
.orElse(new GitRepositoryConfig());
gitRepositoryConfig.setDefaultBranch(branch);
store.set(gitRepositoryConfig);
}
@Override
public void addFileToScm(String name, Path file) {
addToGitWithLfsSupport(name, file);