diff --git a/models/pull.go b/models/pull.go index f86892cbfc92..94cb2a2a032d 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 74185b6815d4..055403d0df33 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -194,10 +194,16 @@ 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 + if err := pr.UpdateCols("status"); err != nil { + log.Error("Unable to update status of pr %d: %v", pr.ID, err) + } continue } checkAndUpdateStatus(pr)