Skip to content

Commit

Permalink
SetDefaultBranch on pushing to empty repository (#7610)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath authored and lunny committed Jul 30, 2019
1 parent a957d4e commit 4d643a5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4d643a5

Please sign in to comment.