From 84f5a0bc62568b6d0a67969e460f4d41339a07d6 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 10 Apr 2021 09:27:29 +0100 Subject: Always set the merge base used to merge the commit (#15352) The issue is that the TestPatch will reset the PR MergeBase - and it is possible for TestPatch to update the MergeBase whilst a merge is ongoing. The ensuing merge will then complete but it doesn't re-set the MergeBase it used to merge the PR. Fixes the intermittent error in git test. Signed-off-by: Andrew Thornton art27@cantab.net --- models/pull.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index 47e699e192..133f196aae 100644 --- a/models/pull.go +++ b/models/pull.go @@ -406,7 +406,8 @@ func (pr *PullRequest) SetMerged() (bool, error) { return false, fmt.Errorf("Issue.changeStatus: %v", err) } - if _, err := sess.Where("id = ?", pr.ID).Cols("has_merged, status, merged_commit_id, merger_id, merged_unix").Update(pr); err != nil { + // We need to save all of the data used to compute this merge as it may have already been changed by TestPatch. FIXME: need to set some state to prevent TestPatch from running whilst we are merging. + if _, err := sess.Where("id = ?", pr.ID).Cols("has_merged, status, merge_base, merged_commit_id, merger_id, merged_unix").Update(pr); err != nil { return false, fmt.Errorf("Failed to update pr[%d]: %v", pr.ID, err) } -- cgit v1.2.3