diff options
author | SagePtr <sageptr@gmail.com> | 2018-09-13 05:40:35 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-09-13 11:40:35 +0800 |
commit | 10a2a904d7938e26f6d64fe9a9788185b802d4df (patch) | |
tree | 5b15c321205a08242a12f94a7316d3ff763495da | |
parent | ea20adaa84cbff762fcaa7f2d5fa6b7bf56706ec (diff) | |
download | gitea-10a2a904d7938e26f6d64fe9a9788185b802d4df.tar.gz gitea-10a2a904d7938e26f6d64fe9a9788185b802d4df.zip |
Fix bug when repo remained bare if multiple branches pushed (#4923)
-rw-r--r-- | models/action.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/models/action.go b/models/action.go index f3f89d143f..9050be22a6 100644 --- a/models/action.go +++ b/models/action.go @@ -537,12 +537,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) } |