From 11327030e708ec612e241d7a46bb4eedec7de1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 25 Mar 2020 09:05:51 +0100 Subject: [PATCH] Tweak whitespace printing in `pr status` --- command/pr.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/command/pr.go b/command/pr.go index 22cd5dcaf..aa22464f4 100644 --- a/command/pr.go +++ b/command/pr.go @@ -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")