@@ -28,8 +28,8 @@ import (
2828 asymkey_service "code.gitea.io/gitea/services/asymkey"
2929)
3030
31- // prPatchCheckerQueue represents a queue to handle update pull request tests
32- var prPatchCheckerQueue queue.UniqueQueue
31+ // prQueue represents a queue to handle update pull request tests
32+ var prQueue queue.UniqueQueue
3333
3434var (
3535 ErrIsClosed = errors .New ("pull is cosed" )
4343
4444// AddToTaskQueue adds itself to pull request test task queue.
4545func AddToTaskQueue (pr * models.PullRequest ) {
46- err := prPatchCheckerQueue .PushFunc (strconv .FormatInt (pr .ID , 10 ), func () error {
46+ err := prQueue .PushFunc (strconv .FormatInt (pr .ID , 10 ), func () error {
4747 pr .Status = models .PullRequestStatusChecking
4848 err := pr .UpdateColsIfNotMerged ("status" )
4949 if err != nil {
@@ -151,7 +151,7 @@ func checkAndUpdateStatus(pr *models.PullRequest) {
151151 }
152152
153153 // Make sure there is no waiting test to process before leaving the checking status.
154- has , err := prPatchCheckerQueue .Has (strconv .FormatInt (pr .ID , 10 ))
154+ has , err := prQueue .Has (strconv .FormatInt (pr .ID , 10 ))
155155 if err != nil {
156156 log .Error ("Unable to check if the queue is waiting to reprocess pr.ID %d. Error: %v" , pr .ID , err )
157157 }
@@ -300,7 +300,7 @@ func InitializePullRequests(ctx context.Context) {
300300 case <- ctx .Done ():
301301 return
302302 default :
303- if err := prPatchCheckerQueue .PushFunc (strconv .FormatInt (prID , 10 ), func () error {
303+ if err := prQueue .PushFunc (strconv .FormatInt (prID , 10 ), func () error {
304304 log .Trace ("Adding PR ID: %d to the pull requests patch checking queue" , prID )
305305 return nil
306306 }); err != nil {
@@ -321,8 +321,6 @@ func handle(data ...queue.Data) []queue.Data {
321321}
322322
323323func testPR (id int64 ) {
324- pullWorkingPool .CheckIn (fmt .Sprint (id ))
325- defer pullWorkingPool .CheckOut (fmt .Sprint (id ))
326324 ctx , _ , finished := process .GetManager ().AddContext (graceful .GetManager ().HammerContext (), fmt .Sprintf ("Test PR[%d] from patch checking queue" , id ))
327325 defer finished ()
328326
@@ -367,13 +365,13 @@ func CheckPrsForBaseBranch(baseRepo *repo_model.Repository, baseBranchName strin
367365
368366// Init runs the task queue to test all the checking status pull requests
369367func Init () error {
370- prPatchCheckerQueue = queue .CreateUniqueQueue ("pr_patch_checker" , handle , "" )
368+ prQueue = queue .CreateUniqueQueue ("pr_patch_checker" , handle , "" )
371369
372- if prPatchCheckerQueue == nil {
370+ if prQueue == nil {
373371 return fmt .Errorf ("Unable to create pr_patch_checker Queue" )
374372 }
375373
376- go graceful .GetManager ().RunWithShutdownFns (prPatchCheckerQueue .Run )
374+ go graceful .GetManager ().RunWithShutdownFns (prQueue .Run )
377375 go graceful .GetManager ().RunWithShutdownContext (InitializePullRequests )
378376 return nil
379377}
0 commit comments