From 50eb5dd5a0771974cfb0e0a3728a47dd83a59b35 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 10 Jan 2020 00:14:14 +0000 Subject: [PATCH 1/2] Move Errored PRs out of StatusChecking (#9675) * Set Errored PRs out of StatusChecking * Ensure that api status is correctly set too * Update models/pull.go Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com> Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com> --- models/pull.go | 3 ++- services/pull/check.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/models/pull.go b/models/pull.go index f86892cbfc924..94cb2a2a032df 100644 --- a/models/pull.go +++ b/models/pull.go @@ -35,6 +35,7 @@ const ( PullRequestStatusChecking PullRequestStatusMergeable PullRequestStatusManuallyMerged + PullRequestStatusError ) // PullRequest represents relation between pull request and repositories. @@ -513,7 +514,7 @@ func (pr *PullRequest) apiFormat(e Engine) *api.PullRequest { } if pr.Status != PullRequestStatusChecking { - mergeable := pr.Status != PullRequestStatusConflict && !pr.IsWorkInProgress() + mergeable := !(pr.Status == PullRequestStatusConflict || pr.Status == PullRequestStatusError) && !pr.IsWorkInProgress() apiPullRequest.Mergeable = mergeable } if pr.HasMerged { diff --git a/services/pull/check.go b/services/pull/check.go index 74185b6815d49..b1b950582318e 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -194,10 +194,14 @@ func TestPullRequests(ctx context.Context) { if err != nil { log.Error("GetPullRequestByID[%s]: %v", prID, err) continue + } else if pr.Status != models.PullRequestStatusChecking { + continue } else if manuallyMerged(pr) { continue } else if err = TestPatch(pr); err != nil { log.Error("testPatch[%d]: %v", pr.ID, err) + pr.Status = models.PullRequestStatusError + pr.UpdateCols("status") continue } checkAndUpdateStatus(pr) From f809923c54ddc23427fd1d9ebced9d89c506deca Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 12 Jan 2020 18:01:58 +0000 Subject: [PATCH 2/2] Update services/pull/check.go --- services/pull/check.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/pull/check.go b/services/pull/check.go index b1b950582318e..055403d0df337 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -201,7 +201,9 @@ func TestPullRequests(ctx context.Context) { } else if err = TestPatch(pr); err != nil { log.Error("testPatch[%d]: %v", pr.ID, err) pr.Status = models.PullRequestStatusError - pr.UpdateCols("status") + if err := pr.UpdateCols("status"); err != nil { + log.Error("Unable to update status of pr %d: %v", pr.ID, err) + } continue } checkAndUpdateStatus(pr)