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".
This commit is contained in:
Mislav Marohnić 2021-03-31 18:21:45 +02:00
parent 23b2594662
commit 05c7c2bd1a
2 changed files with 2 additions and 6 deletions

View file

@ -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++
}

View file

@ -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 := ""