mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-17 11:59:30 +00:00
Display branch commit status (#25608)
Fix #10388
This PR adds a status icon for every branch which has a status check for
the latest commit on branch list page.
<img width="1313" alt="图片"
src="727cd540
-d03a-40c6-a7dd-e87c118af0ac">
This commit is contained in:
parent
5b79eeabd1
commit
7735da1c66
3 changed files with 67 additions and 0 deletions
|
@ -57,7 +57,25 @@ func Branches(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
commitIDs := []string{defaultBranch.DBBranch.CommitID}
|
||||
for _, branch := range branches {
|
||||
commitIDs = append(commitIDs, branch.DBBranch.CommitID)
|
||||
}
|
||||
|
||||
commitStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadBranches", err)
|
||||
return
|
||||
}
|
||||
|
||||
commitStatus := make(map[string]*git_model.CommitStatus)
|
||||
for commitID, cs := range commitStatuses {
|
||||
commitStatus[commitID] = git_model.CalcCommitStatus(cs)
|
||||
}
|
||||
|
||||
ctx.Data["Branches"] = branches
|
||||
ctx.Data["CommitStatus"] = commitStatus
|
||||
ctx.Data["CommitStatuses"] = commitStatuses
|
||||
ctx.Data["DefaultBranchBranch"] = defaultBranch
|
||||
pager := context.NewPagination(int(branchesCount), pageSize, page, 5)
|
||||
pager.SetDefaultParams(ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue