From 037df3fb357e2e1925ca1680968687699aa09495 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Tue, 31 Mar 2020 21:57:08 +0100 Subject: [PATCH 1/3] Only update merge_base if not already merged Fix #10766 Signed-off-by: Andrew Thornton --- 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 c877cc84eeab8..ea91f3a862475 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -61,7 +61,7 @@ func checkAndUpdateStatus(pr *models.PullRequest) { } if !has { - 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 5c7ec91f5d27a..9e4d1d9da2d53 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -120,7 +120,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.UpdateCols("merge_base, status, conflicted_files, base_branch"); err != nil { return err } From 2518d366037c3abbdcb62cb2459505c98c2db04c Mon Sep 17 00:00:00 2001 From: zeripath Date: Tue, 31 Mar 2020 22:21:47 +0100 Subject: [PATCH 2/3] Prevent race in transfer pr --- services/pull/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/pull/pull.go b/services/pull/pull.go index 9e4d1d9da2d53..4a28d745ae9c4 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -120,7 +120,7 @@ func ChangeTargetBranch(pr *models.PullRequest, doer *models.User, targetBranch if pr.Status == models.PullRequestStatusChecking { pr.Status = models.PullRequestStatusMergeable } - if err := pr.UpdateCols("merge_base, status, conflicted_files, base_branch"); err != nil { + if err := pr.UpdateColsIfNotMerged("merge_base, status, conflicted_files, base_branch"); err != nil { return err } From 0ad5f5082eb8dc414f40e5bf7cb393f95236541d Mon Sep 17 00:00:00 2001 From: zeripath Date: Wed, 1 Apr 2020 12:24:43 +0100 Subject: [PATCH 3/3] Update services/pull/pull.go Co-Authored-By: Lauris BH --- services/pull/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/pull/pull.go b/services/pull/pull.go index 4a28d745ae9c4..ce5c4ff22ffc2 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -120,7 +120,7 @@ func ChangeTargetBranch(pr *models.PullRequest, doer *models.User, targetBranch if pr.Status == models.PullRequestStatusChecking { pr.Status = models.PullRequestStatusMergeable } - if err := pr.UpdateColsIfNotMerged("merge_base, status, conflicted_files, base_branch"); err != nil { + if err := pr.UpdateColsIfNotMerged("merge_base", "status", "conflicted_files", "base_branch"); err != nil { return err }