Skip to content

Commit fc539ef

Browse files
committed
fix
1 parent bed6885 commit fc539ef

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

routers/web/repo/repo.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"net/http"
1111
"strings"
12-
"sync"
1312

1413
"code.gitea.io/gitea/models"
1514
"code.gitea.io/gitea/models/db"
@@ -579,20 +578,11 @@ func SearchRepo(ctx *context.Context) {
579578
}
580579

581580
// collect the latest commit of each repo
582-
repoIDsToLatestCommitSHAs := make(map[int64]string)
583-
wg := sync.WaitGroup{}
584-
wg.Add(len(repos))
581+
// at most there are dozens of repos (limited by MaxResponseItems), so it's not a big problem at the moment
582+
repoIDsToLatestCommitSHAs := make(map[int64]string, len(repos))
585583
for _, repo := range repos {
586-
go func(repo *repo_model.Repository) {
587-
defer wg.Done()
588-
commitID, err := repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
589-
if err != nil {
590-
return
591-
}
592-
repoIDsToLatestCommitSHAs[repo.ID] = commitID
593-
}(repo)
584+
repoIDsToLatestCommitSHAs[repo.ID], _ = repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
594585
}
595-
wg.Wait()
596586

597587
// call the database O(1) times to get the commit statuses for all repos
598588
repoToItsLatestCommitStatuses, err := git_model.GetLatestCommitStatusForPairs(ctx, repoIDsToLatestCommitSHAs, db.ListOptions{})

0 commit comments

Comments
 (0)