From bfce841b04a7d1d101ecb84e567e02e4ea33806a Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 1 Apr 2020 13:33:44 +0100 Subject: [PATCH] Only update merge_base if not already merged (#10909) * Only update merge_base if not already merged Fix #10766 Signed-off-by: Andrew Thornton * Prevent race in transfer pull request * Update services/pull/pull.go --- services/pull/check.go | 2 +- services/pull/pull.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/pull/check.go b/services/pull/check.go index e2f39ce16..9ed8f3a08 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -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) } } diff --git a/services/pull/pull.go b/services/pull/pull.go index 2a09c98bf..57e33ec5b 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -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 }