Browse Source

improve branches list performance and fix protected branch icon when no-login (#7695)

tags/v1.11.0-dev
Lunny Xiao techknowlogick 5 years ago
parent
commit
14574c4b39
1 changed files with 12 additions and 4 deletions
  1. +12
    -4
      routers/repo/branch.go

+ 12
- 4
routers/repo/branch.go View File

@@ -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()
@@ -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)


Loading…
Cancel
Save