From 05c7c2bd1aeee25efbd158219691b9015bbdb8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 31 Mar 2021 18:21:45 +0200 Subject: [PATCH] Treat unrecognized PR Checks statuses as "pending" Previously, unrecognized Checks statuses would crash the program. For the sake of supporting the "WAITING" status and for forward-compatibility, this treats any unrecognized status as "pending". --- api/queries_pr.go | 4 +--- pkg/cmd/pr/checks/checks.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/api/queries_pr.go b/api/queries_pr.go index 74b7dd170..9b4661e37 100644 --- a/api/queries_pr.go +++ b/api/queries_pr.go @@ -188,10 +188,8 @@ func (pr *PullRequest) ChecksStatus() (summary PullRequestChecksStatus) { summary.Passing++ case "ERROR", "FAILURE", "CANCELLED", "TIMED_OUT", "ACTION_REQUIRED": summary.Failing++ - case "EXPECTED", "REQUESTED", "QUEUED", "PENDING", "IN_PROGRESS", "STALE": + default: // "EXPECTED", "REQUESTED", "WAITING", "QUEUED", "PENDING", "IN_PROGRESS", "STALE" summary.Pending++ - default: - panic(fmt.Errorf("unsupported status: %q", state)) } summary.Total++ } diff --git a/pkg/cmd/pr/checks/checks.go b/pkg/cmd/pr/checks/checks.go index 83f4ce567..515c9b0b5 100644 --- a/pkg/cmd/pr/checks/checks.go +++ b/pkg/cmd/pr/checks/checks.go @@ -141,13 +141,11 @@ func checksRun(opts *ChecksOptions) error { markColor = cs.Red failing++ bucket = "fail" - case "EXPECTED", "REQUESTED", "QUEUED", "PENDING", "IN_PROGRESS", "STALE": + default: // "EXPECTED", "REQUESTED", "WAITING", "QUEUED", "PENDING", "IN_PROGRESS", "STALE" mark = "-" markColor = cs.Yellow pending++ bucket = "pending" - default: - panic(fmt.Errorf("unsupported status: %q", state)) } elapsed := ""