Get latest commit statuses from database instead of git data on dashboard for repositories (#25605)
related #24638
This commit is contained in:
parent
640a88fa09
commit
807c9712ef
2 changed files with 25 additions and 6 deletions
|
@ -130,3 +130,20 @@ func FindBranchNames(ctx context.Context, opts FindBranchOptions) ([]string, err
|
|||
}
|
||||
return branches, nil
|
||||
}
|
||||
|
||||
func FindBranchesByRepoAndBranchName(ctx context.Context, repoBranches map[int64]string) (map[int64]string, error) {
|
||||
cond := builder.NewCond()
|
||||
for repoID, branchName := range repoBranches {
|
||||
cond = cond.Or(builder.And(builder.Eq{"repo_id": repoID}, builder.Eq{"name": branchName}))
|
||||
}
|
||||
var branches []*Branch
|
||||
if err := db.GetEngine(ctx).
|
||||
Where(cond).Find(&branches); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
branchMap := make(map[int64]string, len(branches))
|
||||
for _, branch := range branches {
|
||||
branchMap[branch.RepoID] = branch.CommitID
|
||||
}
|
||||
return branchMap, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue