@@ -128,14 +128,7 @@ func NewPullRequest(ctx context.Context, opts *NewPullRequestOptions) error {
128128		}
129129
130130		// Update Commit Divergence 
131- 		divergence , err  :=  GetDiverging (ctx , pr )
132- 		if  err  !=  nil  {
133- 			return  err 
134- 		}
135- 		pr .CommitsAhead  =  divergence .Ahead 
136- 		pr .CommitsBehind  =  divergence .Behind 
137- 
138- 		err  =  pr .UpdateCommitDivergence (ctx , divergence .Ahead , divergence .Behind )
131+ 		err  =  UpdateCommitDivergence (ctx , pr )
139132		if  err  !=  nil  {
140133			return  err 
141134		}
@@ -433,14 +426,8 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
433426						if  err  :=  issues_model .MarkReviewsAsNotStale (ctx , pr .IssueID , opts .NewCommitID ); err  !=  nil  {
434427							log .Error ("MarkReviewsAsNotStale: %v" , err )
435428						}
436- 						divergence , err  :=  GetDiverging (ctx , pr )
437- 						if  err  !=  nil  {
438- 							log .Error ("GetDiverging: %v" , err )
439- 						} else  {
440- 							err  =  pr .UpdateCommitDivergence (ctx , divergence .Ahead , divergence .Behind )
441- 							if  err  !=  nil  {
442- 								log .Error ("UpdateCommitDivergence: %v" , err )
443- 							}
429+ 						if  err  =  UpdateCommitDivergence (ctx , pr ); err  !=  nil  {
430+ 							log .Error ("UpdateCommitDivergence: %v" , err )
444431						}
445432					}
446433
@@ -474,18 +461,14 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
474461		}
475462		for  _ , pr  :=  range  prs  {
476463			pr .BaseRepo  =  baseRepo  // avoid loading again 
477- 			divergence ,  err  :=   GetDiverging (ctx , pr )
464+ 			err  =   UpdateCommitDivergence (ctx , pr )
478465			if  err  !=  nil  {
479- 				if  git_model . IsErrBranchNotExist (err )  &&   ! gitrepo . IsBranchExist ( ctx ,  pr . HeadRepo ,  pr . HeadBranch ) {
480- 					log .Warn ("Cannot test PR %s/%d: head_branch  %s no longer exists" , pr .BaseRepo .Name , pr .IssueID , pr .HeadBranch )
466+ 				if  errors . Is (err ,  util . ErrNotExist ) {
467+ 					log .Warn ("Cannot test PR %s/%d with base= %s head=%s:  no longer exists" , pr .BaseRepo .FullName () , pr .IssueID ,  pr . BaseBranch , pr .HeadBranch )
481468				} else  {
482- 					log .Error ("GetDiverging: %v" , err )
483- 				}
484- 			} else  {
485- 				err  =  pr .UpdateCommitDivergence (ctx , divergence .Ahead , divergence .Behind )
486- 				if  err  !=  nil  {
487469					log .Error ("UpdateCommitDivergence: %v" , err )
488470				}
471+ 				continue 
489472			}
490473			StartPullRequestCheckDelayable (ctx , pr )
491474		}
0 commit comments