From c9bcf807b1445f4e6ad45672315e4585c999fe79 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 8 Jan 2020 12:31:23 -0800 Subject: [PATCH] Make it work with PRs --- command/issue.go | 2 +- command/pr.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/command/issue.go b/command/issue.go index 48cc05ce9..cc114d728 100644 --- a/command/issue.go +++ b/command/issue.go @@ -329,7 +329,7 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue) } remaining := totalCount - len(issues) if remaining > 0 { - fmt.Fprintf(w, utils.Gray("%sAnd %d more"), prefix, remaining) + fmt.Fprintf(w, utils.Gray("%sAnd %d more\n"), prefix, remaining) } } diff --git a/command/pr.go b/command/pr.go index cb20bf804..cdf5dd6bc 100644 --- a/command/pr.go +++ b/command/pr.go @@ -97,11 +97,9 @@ func prStatus(cmd *cobra.Command, args []string) error { out := colorableOut(cmd) - fmt.Printf("🌭 %+v\n", prPayload) - printHeader(out, "Current branch") if prPayload.CurrentPR != nil { - printPrs(out, *prPayload.CurrentPR) + printPrs(out, 0, *prPayload.CurrentPR) } else { message := fmt.Sprintf(" There is no pull request associated with %s", utils.Cyan("["+currentPRHeadRef+"]")) printMessage(out, message) @@ -110,7 +108,7 @@ func prStatus(cmd *cobra.Command, args []string) error { printHeader(out, "Created by you") if prPayload.ViewerCreated.TotalCount > 0 { - printPrs(out, prPayload.ViewerCreated.PullRequests...) + printPrs(out, prPayload.ViewerCreated.TotalCount, prPayload.ViewerCreated.PullRequests...) } else { printMessage(out, " You have no open pull requests") } @@ -118,7 +116,7 @@ func prStatus(cmd *cobra.Command, args []string) error { printHeader(out, "Requesting a code review from you") if prPayload.ReviewRequested.TotalCount > 0 { - printPrs(out, prPayload.ReviewRequested.PullRequests...) + printPrs(out, prPayload.ReviewRequested.TotalCount, prPayload.ReviewRequested.PullRequests...) } else { printMessage(out, " You have no pull requests to review") } @@ -437,7 +435,7 @@ func prCheckout(cmd *cobra.Command, args []string) error { return nil } -func printPrs(w io.Writer, prs ...api.PullRequest) { +func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) { for _, pr := range prs { prNumber := fmt.Sprintf("#%d", pr.Number) fmt.Fprintf(w, " %s %s %s", utils.Green(prNumber), truncate(50, replaceExcessiveWhitespace(pr.Title)), utils.Cyan("["+pr.HeadLabel()+"]")) @@ -474,6 +472,10 @@ func printPrs(w io.Writer, prs ...api.PullRequest) { fmt.Fprint(w, "\n") } + remaining := totalCount - len(prs) + if remaining > 0 { + fmt.Fprintf(w, utils.Gray(" And %d more\n"), remaining) + } } func printHeader(w io.Writer, s string) {