Tweak whitespace printing in pr status

This commit is contained in:
Mislav Marohnić 2020-03-25 09:05:51 +01:00
parent 7c73cf88ae
commit 11327030e7

View file

@ -398,13 +398,15 @@ func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) {
prStateColorFunc = utils.Red
}
fmt.Fprintf(w, " %s %s %s ", prStateColorFunc(prNumber), text.Truncate(50, replaceExcessiveWhitespace(pr.Title)), utils.Cyan("["+pr.HeadLabel()+"]"))
fmt.Fprintf(w, " %s %s %s", prStateColorFunc(prNumber), text.Truncate(50, replaceExcessiveWhitespace(pr.Title)), utils.Cyan("["+pr.HeadLabel()+"]"))
checks := pr.ChecksStatus()
reviews := pr.ReviewStatus()
if pr.State == "OPEN" {
if checks.Total > 0 || reviews.ChangesRequested || reviews.Approved {
reviewStatus := reviews.ChangesRequested || reviews.Approved || reviews.ReviewRequired
if checks.Total > 0 || reviewStatus {
// show checks & reviews on their own line
fmt.Fprintf(w, "\n ")
}
@ -412,28 +414,33 @@ func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) {
var summary string
if checks.Failing > 0 {
if checks.Failing == checks.Total {
summary = utils.Red("× All checks failing ")
summary = utils.Red("× All checks failing")
} else {
summary = utils.Red(fmt.Sprintf("× %d/%d checks failing ", checks.Failing, checks.Total))
summary = utils.Red(fmt.Sprintf("× %d/%d checks failing", checks.Failing, checks.Total))
}
} else if checks.Pending > 0 {
summary = utils.Yellow("- Checks pending ")
summary = utils.Yellow("- Checks pending")
} else if checks.Passing == checks.Total {
summary = utils.Green("✓ Checks passing ")
summary = utils.Green("✓ Checks passing")
}
fmt.Fprint(w, summary)
}
if checks.Total > 0 && reviewStatus {
// add padding between checks & reviews
fmt.Fprint(w, " ")
}
if reviews.ChangesRequested {
fmt.Fprintf(w, "%s", utils.Red("+ Changes requested "))
fmt.Fprint(w, utils.Red("+ Changes requested"))
} else if reviews.ReviewRequired {
fmt.Fprintf(w, "%s", utils.Yellow("- Review required "))
fmt.Fprint(w, utils.Yellow("- Review required"))
} else if reviews.Approved {
fmt.Fprintf(w, "%s", utils.Green("✓ Approved "))
fmt.Fprint(w, utils.Green("✓ Approved"))
}
} else {
s := strings.Title(strings.ToLower(pr.State))
fmt.Fprintf(w, "- %s", prStateColorFunc(s))
fmt.Fprintf(w, " - %s", prStateColorFunc(s))
}
fmt.Fprint(w, "\n")