@@ -560,8 +560,7 @@ func UpdatePullsRefs(ctx context.Context, repo *repo_model.Repository, update *r
560560func  UpdatePullRequestAgitFlowHead (ctx  context.Context , pr  * issues_model.PullRequest , commitID  string ) error  {
561561	log .Trace ("UpdateAgitPullRequestHead[%d]: update pull request head in base repo '%s'" , pr .ID , pr .GetGitHeadRefName ())
562562
563- 	_ , _ , err  :=  gitcmd .NewCommand ("update-ref" ).AddDynamicArguments (pr .GetGitHeadRefName (), commitID ).RunStdString (ctx , & gitcmd.RunOpts {Dir : pr .BaseRepo .RepoPath ()})
564- 	return  err 
563+ 	return  gitrepo .UpdateRef (ctx , pr .BaseRepo , pr .GetGitHeadRefName (), commitID )
565564}
566565
567566// UpdatePullRequestHeadRef updates the head reference of a pull request 
@@ -572,21 +571,17 @@ func UpdatePullRequestGithubFlowHead(ctx context.Context, pr *issues_model.PullR
572571		return  err 
573572	}
574573
575- 	if  err  :=  gitrepo .UpdateRef (ctx , pr .BaseRepo , pr .GetGitHeadRefName (), pr .HeadCommitID ); err  !=  nil  {
576- 		log .Error ("Unable to update ref in base repository for PR[%d] Error: %v" , pr .ID , err )
577- 	}
574+ 	if  ! pr .IsSameRepo () { // for cross repository pull request 
575+ 		if  err  :=  pr .LoadHeadRepo (ctx ); err  !=  nil  {
576+ 			return  err 
577+ 		}
578578
579- 	// for cross repository pull request 
580- 	if  err   :=   pr . LoadHeadRepo ( ctx );  err   !=   nil  { 
581- 		return   err 
579+ 		 if   err   :=   gitrepo . FetchRemoteBranch ( ctx ,  pr . BaseRepo ,  pr . GetGitHeadRefName (),  pr . HeadRepo ,  pr . HeadBranch );  err   !=   nil  { 
580+ 			 return  err 
581+ 		} 
582582	}
583583
584- 	_ , _ , err  :=  gitcmd .NewCommand ("fetch" , "--no-tags" , "--refmap=" ).
585- 		AddDynamicArguments (pr .HeadRepo .RepoPath ()).
586- 		// + means force fetch 
587- 		AddDynamicArguments (fmt .Sprintf ("+refs/heads/%s:%s" , pr .HeadBranch , pr .GetGitHeadRefName ())).
588- 		RunStdString (ctx , & gitcmd.RunOpts {Dir : pr .BaseRepo .RepoPath ()})
589- 	return  err 
584+ 	return  gitrepo .UpdateRef (ctx , pr .BaseRepo , pr .GetGitHeadRefName (), pr .HeadCommitID )
590585}
591586
592587// retargetBranchPulls change target branch for all pull requests whose base branch is the branch 
0 commit comments