Skip to content

Commit 10a2a90

Browse files
SagePtrlunny
authored andcommitted
Fix bug when repo remained bare if multiple branches pushed (#4923)
1 parent ea20ada commit 10a2a90

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

models/action.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,14 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
537537
}
538538

539539
refName := git.RefEndName(opts.RefFullName)
540-
if repo.IsBare && refName != repo.DefaultBranch {
540+
541+
// Change default branch and bare status only if pushed ref is non-empty branch.
542+
if repo.IsBare && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
541543
repo.DefaultBranch = refName
544+
repo.IsBare = false
542545
}
543546

544547
// Change repository bare status and update last updated time.
545-
repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
546548
if err = UpdateRepository(repo, false); err != nil {
547549
return fmt.Errorf("UpdateRepository: %v", err)
548550
}

0 commit comments

Comments
 (0)