@@ -34,7 +34,6 @@ import (
3434
3535// Merge merges pull request to base repository.
3636// Caller should check PR is ready to be merged (review and status checks)
37- // FIXME: add repoWorkingPull make sure two merges does not happen at same time.
3837func Merge (pr * models.PullRequest , doer * user_model.User , baseGitRepo * git.Repository , mergeStyle repo_model.MergeStyle , expectedHeadCommitID , message string ) error {
3938 if err := pr .LoadHeadRepo (); err != nil {
4039 log .Error ("LoadHeadRepo: %v" , err )
@@ -44,6 +43,9 @@ func Merge(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repos
4443 return fmt .Errorf ("LoadBaseRepo: %v" , err )
4544 }
4645
46+ pullWorkingPool .CheckIn (fmt .Sprint (pr .ID ))
47+ defer pullWorkingPool .CheckOut (fmt .Sprint (pr .ID ))
48+
4749 prUnit , err := pr .BaseRepo .GetUnit (unit .TypePullRequests )
4850 if err != nil {
4951 log .Error ("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v" , err )
@@ -726,6 +728,9 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski
726728
727729// MergedManually mark pr as merged manually
728730func MergedManually (pr * models.PullRequest , doer * user_model.User , baseGitRepo * git.Repository , commitID string ) error {
731+ pullWorkingPool .CheckIn (fmt .Sprint (pr .ID ))
732+ defer pullWorkingPool .CheckOut (fmt .Sprint (pr .ID ))
733+
729734 if err := db .WithTx (func (ctx context.Context ) error {
730735 prUnit , err := pr .BaseRepo .GetUnitCtx (ctx , unit .TypePullRequests )
731736 if err != nil {
0 commit comments