Skip to content

Commit

Permalink
Fix bug when repo remained bare if multiple branches pushed (#4923)
Browse files Browse the repository at this point in the history
  • Loading branch information
SagePtr authored and lunny committed Sep 13, 2018
1 parent ea20ada commit 10a2a90
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 10a2a90

Please sign in to comment.