Skip to content

Commit

Permalink
improve branches list performance and fix protected branch icon when …
Browse files Browse the repository at this point in the history
…no-login (#7695) (#7704)
  • Loading branch information
lunny authored and techknowlogick committed Aug 1, 2019
1 parent 39da4ac commit d15e49f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions routers/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ func loadBranches(ctx *context.Context) []*Branch {
return nil
}

protectedBranches, err := ctx.Repo.Repository.GetProtectedBranches()
if err != nil {
ctx.ServerError("GetProtectedBranches", err)
return nil
}

branches := make([]*Branch, len(rawBranches))
for i := range rawBranches {
commit, err := rawBranches[i].GetCommit()
Expand All @@ -170,11 +176,13 @@ func loadBranches(ctx *context.Context) []*Branch {
return nil
}

var isProtected bool
branchName := rawBranches[i].Name
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName, ctx.User)
if err != nil {
ctx.ServerError("IsProtectedBranch", err)
return nil
for _, b := range protectedBranches {
if b.BranchName == branchName {
isProtected = true
break
}
}

divergence, divergenceError := repofiles.CountDivergingCommits(ctx.Repo.Repository, branchName)
Expand Down

0 comments on commit d15e49f

Please sign in to comment.