Fix bug when repo remained bare if multiple branches pushed (#4927)

This commit is contained in:
SagePtr 2018-09-13 12:36:41 +02:00 committed by Lauris BH
부모 1a68b3962f
커밋 c145cb745b
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제

파일 보기

@ -524,12 +524,14 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
}
refName := git.RefEndName(opts.RefFullName)
if repo.IsBare && refName != repo.DefaultBranch {
// Change default branch and bare status only if pushed ref is non-empty branch.
if repo.IsBare && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
repo.DefaultBranch = refName
repo.IsBare = false
}
// Change repository bare status and update last updated time.
repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
if err = UpdateRepository(repo, false); err != nil {
return fmt.Errorf("UpdateRepository: %v", err)
}