From 39f535f0a179d0dcf1de0078e97acb07cf8acc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 19 Nov 2019 12:01:46 +0100 Subject: [PATCH] Only show ratio of PR checks when some are failing Now the possible outputs are: - "checks: pending" (yellow) - "checks: success" (green) - "checks: failing" (red) - 1 out of 1 check failed - "checks: 3/5 failing" (red) - 3 out of 5 checks failed --- command/pr.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/command/pr.go b/command/pr.go index 924ce1666..775d10d6c 100644 --- a/command/pr.go +++ b/command/pr.go @@ -361,29 +361,20 @@ func printPrs(prs ...api.PullRequest) { fmt.Printf("\n ") } - if checks.Total > 1 { - var ratio string + if checks.Total > 0 { + var summary string if checks.Failing > 0 { - ratio = fmt.Sprintf("%d/%d", checks.Passing, checks.Total) - ratio = utils.Red(ratio) + if checks.Total > 1 { + summary = utils.Red(fmt.Sprintf("%d/%d failing", checks.Failing, checks.Total)) + } else { + summary = utils.Red("failing") + } } else if checks.Pending > 0 { - ratio = fmt.Sprintf("%d/%d", checks.Passing, checks.Total) - ratio = utils.Yellow(ratio) + summary = utils.Yellow("pending") } else if checks.Passing == checks.Total { - ratio = fmt.Sprintf("%d", checks.Total) - ratio = utils.Green(ratio) + summary = utils.Green("success") } - fmt.Printf(" - checks: %s", ratio) - } else if checks.Total == 1 { - var state string - if checks.Failing > 0 { - state = utils.Red("failing") - } else if checks.Pending > 0 { - state = utils.Yellow("pending") - } else if checks.Passing == checks.Total { - state = utils.Green("success") - } - fmt.Printf(" - checks: %s", state) + fmt.Printf(" - checks: %s", summary) } if reviews.ChangesRequested {