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
This commit is contained in:
Mislav Marohnić 2019-11-19 12:01:46 +01:00
parent f58b7ecb3e
commit 39f535f0a1

View file

@ -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 {