Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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