mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 21:35:35 +03:00
improve branches list performance and fix protected branch icon when no-login (#7695)
This commit is contained in:
parent
a4b7a4f2f8
commit
02999c9a44
1 changed files with 12 additions and 4 deletions
|
@ -162,6 +162,12 @@ func loadBranches(ctx *context.Context) []*Branch {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protectedBranches, err := ctx.Repo.Repository.GetProtectedBranches()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GetProtectedBranches", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
branches := make([]*Branch, len(rawBranches))
|
branches := make([]*Branch, len(rawBranches))
|
||||||
for i := range rawBranches {
|
for i := range rawBranches {
|
||||||
commit, err := rawBranches[i].GetCommit()
|
commit, err := rawBranches[i].GetCommit()
|
||||||
|
@ -170,11 +176,13 @@ func loadBranches(ctx *context.Context) []*Branch {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isProtected bool
|
||||||
branchName := rawBranches[i].Name
|
branchName := rawBranches[i].Name
|
||||||
isProtected, err := ctx.Repo.Repository.IsProtectedBranch(branchName, ctx.User)
|
for _, b := range protectedBranches {
|
||||||
if err != nil {
|
if b.BranchName == branchName {
|
||||||
ctx.ServerError("IsProtectedBranch", err)
|
isProtected = true
|
||||||
return nil
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
divergence, divergenceError := repofiles.CountDivergingCommits(ctx.Repo.Repository, branchName)
|
divergence, divergenceError := repofiles.CountDivergingCommits(ctx.Repo.Repository, branchName)
|
||||||
|
|
Loading…
Reference in a new issue