Skip to content

Commit d1eac7b

Browse files
committed
pr status: avoid printing a lonely "1" when there is only one Check
In a repository that only has a single Check configured (e.g. this repo), we would print "checks: 1" for PRs where the CI is passing. This looks akward when repeated for each PR and provides little useful information. This avoids ever printing "1" and instead prints "failing", "pending", or "success", respectively. We now only show numbers for repositories that have more than one Check runs.
1 parent 624c44e commit d1eac7b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

command/pr.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func printPrs(prs ...api.PullRequest) {
258258
fmt.Printf("\n ")
259259
}
260260

261-
if checks.Total > 0 {
261+
if checks.Total > 1 {
262262
var ratio string
263263
if checks.Failing > 0 {
264264
ratio = fmt.Sprintf("%d/%d", checks.Passing, checks.Total)
@@ -271,6 +271,16 @@ func printPrs(prs ...api.PullRequest) {
271271
ratio = utils.Green(ratio)
272272
}
273273
fmt.Printf(" - checks: %s", ratio)
274+
} else if checks.Total == 1 {
275+
var state string
276+
if checks.Failing > 0 {
277+
state = utils.Red("failing")
278+
} else if checks.Pending > 0 {
279+
state = utils.Yellow("pending")
280+
} else if checks.Passing == checks.Total {
281+
state = utils.Green("success")
282+
}
283+
fmt.Printf(" - checks: %s", state)
274284
}
275285

276286
if reviews.ChangesRequested {

0 commit comments

Comments
 (0)