···579579580580 // collect the latest commit of each repo
581581 // at most there are dozens of repos (limited by MaxResponseItems), so it's not a big problem at the moment
582582- repoIDsToLatestCommitSHAs := make(map[int64]string, len(repos))
582582+ repoBranchNames := make(map[int64]string, len(repos))
583583 for _, repo := range repos {
584584- commitID, err := repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
585585- if err != nil {
586586- continue
587587- }
588588- repoIDsToLatestCommitSHAs[repo.ID] = commitID
584584+ repoBranchNames[repo.ID] = repo.DefaultBranch
585585+ }
586586+587587+ repoIDsToLatestCommitSHAs, err := git_model.FindBranchesByRepoAndBranchName(ctx, repoBranchNames)
588588+ if err != nil {
589589+ log.Error("FindBranchesByRepoAndBranchName: %v", err)
590590+ return
589591 }
590592591593 // call the database O(1) times to get the commit statuses for all repos