Commit 4d643a59 authored by zeripath's avatar zeripath Committed by Lunny Xiao
Browse files

SetDefaultBranch on pushing to empty repository (#7610)

Showing with 11 additions and 0 deletions
+11 -0
......@@ -685,6 +685,17 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
if repo.IsEmpty && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
repo.DefaultBranch = refName
repo.IsEmpty = false
if refName != "master" {
gitRepo, err := git.OpenRepository(repo.RepoPath())
if err != nil {
return err
}
if err := gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil {
if !git.IsErrUnsupportedVersion(err) {
return err
}
}
}
}
// Change repository empty status and update last updated time.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment