From c145cb745b01b50ab44717be385fb751a25f6971 Mon Sep 17 00:00:00 2001 From: SagePtr Date: Thu, 13 Sep 2018 12:36:41 +0200 Subject: [PATCH] Fix bug when repo remained bare if multiple branches pushed (#4927) --- models/action.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/action.go b/models/action.go index c3ed9c7c0..8a7ee1264 100644 --- a/models/action.go +++ b/models/action.go @@ -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) }