summaryrefslogtreecommitdiffstats
path: root/services/pull/check.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-02-09 23:09:31 +0000
committerGitHub <noreply@github.com>2020-02-10 01:09:31 +0200
commit875c5e13050e4f7b95773c3b8ef5deac8b4b581b (patch)
tree226be9ed66641915fb4d3c623e423c3c87bcd3a0 /services/pull/check.go
parent585316f3bf567f8714054babab91280afdaa332b (diff)
downloadgitea-875c5e13050e4f7b95773c3b8ef5deac8b4b581b.tar.gz
gitea-875c5e13050e4f7b95773c3b8ef5deac8b4b581b.zip
Only check for conflicts/merging if the PR has not been merged in the interim (#10132)
* Only check for merging if the PR has not been merged in the interim * fixup! Only check for merging if the PR has not been merged in the interim * Try to fix test failure * Use PR2 not PR1 in tests as PR1 merges automatically * return already merged error * enforce locking * enforce locking - fix-test * enforce locking - fix-testx2 * enforce locking - fix-testx3 * move pullrequest checking to after merge This might improve the chance that the race does not affect us but does not prevent it. * Remove minor race with getting merge commit id * fixup * move check pr after merge * Remove unnecessary prepareTestEnv - onGiteaRun does this for us * Add information about when merging occuring * fix fmt * More logging * Attempt to fix mysql * Try MySQL fix again * try again * Try again?! * Try again?! * Sigh * remove the count - perhaps that will help * next remove the update id * next remove the update id - make it updated_unix instead * On failure to merge ensure that the pr is rechecked for conflict errors * On failure to merge ensure that the pr is rechecked for conflict errors * Update models/pull.go * Update models/pull.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'services/pull/check.go')
-rw-r--r--services/pull/check.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/services/pull/check.go b/services/pull/check.go
index d64f49de3b..17f9e047a5 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -32,7 +32,7 @@ func AddToTaskQueue(pr *models.PullRequest) {
go func() {
err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error {
pr.Status = models.PullRequestStatusChecking
- err := pr.UpdateCols("status")
+ err := pr.UpdateColsIfNotMerged("status")
if err != nil {
log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
} else {
@@ -158,9 +158,11 @@ func manuallyMerged(pr *models.PullRequest) bool {
pr.Merger = merger
pr.MergerID = merger.ID
- if err = pr.SetMerged(); err != nil {
+ if merged, err := pr.SetMerged(); err != nil {
log.Error("PullRequest[%d].setMerged : %v", pr.ID, err)
return false
+ } else if !merged {
+ return false
}
notification.NotifyMergePullRequest(pr, merger)
@@ -205,7 +207,7 @@ func handle(data ...queue.Data) {
if err != nil {
log.Error("GetPullRequestByID[%s]: %v", prID, err)
continue
- } else if pr.Status != models.PullRequestStatusChecking {
+ } else if pr.HasMerged {
continue
} else if manuallyMerged(pr) {
continue