Skip to content

Commit c9bcf80

Browse files
committed
Make it work with PRs
1 parent 4fcf13d commit c9bcf80

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

command/issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func printIssues(w io.Writer, prefix string, totalCount int, issues []api.Issue)
329329
}
330330
remaining := totalCount - len(issues)
331331
if remaining > 0 {
332-
fmt.Fprintf(w, utils.Gray("%sAnd %d more"), prefix, remaining)
332+
fmt.Fprintf(w, utils.Gray("%sAnd %d more\n"), prefix, remaining)
333333
}
334334
}
335335

command/pr.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ func prStatus(cmd *cobra.Command, args []string) error {
9797

9898
out := colorableOut(cmd)
9999

100-
fmt.Printf("🌭 %+v\n", prPayload)
101-
102100
printHeader(out, "Current branch")
103101
if prPayload.CurrentPR != nil {
104-
printPrs(out, *prPayload.CurrentPR)
102+
printPrs(out, 0, *prPayload.CurrentPR)
105103
} else {
106104
message := fmt.Sprintf(" There is no pull request associated with %s", utils.Cyan("["+currentPRHeadRef+"]"))
107105
printMessage(out, message)
@@ -110,15 +108,15 @@ func prStatus(cmd *cobra.Command, args []string) error {
110108

111109
printHeader(out, "Created by you")
112110
if prPayload.ViewerCreated.TotalCount > 0 {
113-
printPrs(out, prPayload.ViewerCreated.PullRequests...)
111+
printPrs(out, prPayload.ViewerCreated.TotalCount, prPayload.ViewerCreated.PullRequests...)
114112
} else {
115113
printMessage(out, " You have no open pull requests")
116114
}
117115
fmt.Fprintln(out)
118116

119117
printHeader(out, "Requesting a code review from you")
120118
if prPayload.ReviewRequested.TotalCount > 0 {
121-
printPrs(out, prPayload.ReviewRequested.PullRequests...)
119+
printPrs(out, prPayload.ReviewRequested.TotalCount, prPayload.ReviewRequested.PullRequests...)
122120
} else {
123121
printMessage(out, " You have no pull requests to review")
124122
}
@@ -437,7 +435,7 @@ func prCheckout(cmd *cobra.Command, args []string) error {
437435
return nil
438436
}
439437

440-
func printPrs(w io.Writer, prs ...api.PullRequest) {
438+
func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) {
441439
for _, pr := range prs {
442440
prNumber := fmt.Sprintf("#%d", pr.Number)
443441
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) {
474472

475473
fmt.Fprint(w, "\n")
476474
}
475+
remaining := totalCount - len(prs)
476+
if remaining > 0 {
477+
fmt.Fprintf(w, utils.Gray(" And %d more\n"), remaining)
478+
}
477479
}
478480

479481
func printHeader(w io.Writer, s string) {

0 commit comments

Comments
 (0)