From d1eac7b211b7087bae0abf76529b7f7ceb26268c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 15 Nov 2019 12:35:44 +0100 Subject: [PATCH 1/3] `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. --- command/pr.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/command/pr.go b/command/pr.go index 0445b81d6..1ae542323 100644 --- a/command/pr.go +++ b/command/pr.go @@ -258,7 +258,7 @@ func printPrs(prs ...api.PullRequest) { fmt.Printf("\n ") } - if checks.Total > 0 { + if checks.Total > 1 { var ratio string if checks.Failing > 0 { ratio = fmt.Sprintf("%d/%d", checks.Passing, checks.Total) @@ -271,6 +271,16 @@ func printPrs(prs ...api.PullRequest) { ratio = utils.Green(ratio) } 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) } if reviews.ChangesRequested { 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 2/3] 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 { From 26c1e4a170a3e185247d781bb089ea0490466eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 20 Nov 2019 12:00:24 +0100 Subject: [PATCH 3/3] Align checks wording with dotcom --- command/pr.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/command/pr.go b/command/pr.go index 775d10d6c..203995554 100644 --- a/command/pr.go +++ b/command/pr.go @@ -364,17 +364,17 @@ func printPrs(prs ...api.PullRequest) { if checks.Total > 0 { var summary string if checks.Failing > 0 { - if checks.Total > 1 { - summary = utils.Red(fmt.Sprintf("%d/%d failing", checks.Failing, checks.Total)) + if checks.Failing == checks.Total { + summary = utils.Red("All checks failing") } else { - summary = utils.Red("failing") + summary = utils.Red(fmt.Sprintf("%d/%d checks failing", checks.Failing, checks.Total)) } } else if checks.Pending > 0 { - summary = utils.Yellow("pending") + summary = utils.Yellow("Checks pending") } else if checks.Passing == checks.Total { - summary = utils.Green("success") + summary = utils.Green("Checks passing") } - fmt.Printf(" - checks: %s", summary) + fmt.Printf(" - %s", summary) } if reviews.ChangesRequested {