]> source.dussan.org Git - gitea.git/commitdiff
Only update merge_base if not already merged (#10909)
authorzeripath <art27@cantab.net>
Wed, 1 Apr 2020 12:33:44 +0000 (13:33 +0100)
committerGitHub <noreply@github.com>
Wed, 1 Apr 2020 12:33:44 +0000 (15:33 +0300)
* Only update merge_base if not already merged

Fix #10766

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Prevent race in transfer pull request

* Update services/pull/pull.go

services/pull/check.go
services/pull/pull.go

index e2f39ce1639c262e7348f2ec7bef06f2c9383961..9ed8f3a08fb0788fbf427263f4125ac56f90b138 100644 (file)
@@ -47,7 +47,7 @@ func checkAndUpdateStatus(pr *models.PullRequest) {
 
        // Make sure there is no waiting test to process before leaving the checking status.
        if !pullRequestQueue.Exist(pr.ID) {
-               if err := pr.UpdateCols("merge_base", "status", "conflicted_files"); err != nil {
+               if err := pr.UpdateColsIfNotMerged("merge_base", "status", "conflicted_files"); err != nil {
                        log.Error("Update[%d]: %v", pr.ID, err)
                }
        }
index 2a09c98bfe6165722de1f7c876ea2206252420cd..57e33ec5beca1df1b41748a4d5b1b6767bf672df 100644 (file)
@@ -115,7 +115,7 @@ func ChangeTargetBranch(pr *models.PullRequest, doer *models.User, targetBranch
        if pr.Status == models.PullRequestStatusChecking {
                pr.Status = models.PullRequestStatusMergeable
        }
-       if err := pr.UpdateCols("status, conflicted_files, base_branch"); err != nil {
+       if err := pr.UpdateColsIfNotMerged("merge_base", "status", "conflicted_files", "base_branch"); err != nil {
                return err
        }