Skip to content

Commit c145cb7

Browse files
SagePtrlafriks
authored andcommitted
Fix bug when repo remained bare if multiple branches pushed (#4927)
1 parent 1a68b39 commit c145cb7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

models/action.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,14 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
524524
}
525525

526526
refName := git.RefEndName(opts.RefFullName)
527-
if repo.IsBare && refName != repo.DefaultBranch {
527+
528+
// Change default branch and bare status only if pushed ref is non-empty branch.
529+
if repo.IsBare && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
528530
repo.DefaultBranch = refName
531+
repo.IsBare = false
529532
}
530533

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

0 commit comments

Comments
 (0)