From 906f49659fa85e3496425454371519302cec36ed Mon Sep 17 00:00:00 2001 From: UmairShahzad <18100099@lums.edu.pk> Date: Sat, 15 Feb 2020 22:37:13 +0500 Subject: [PATCH] updated title and tests --- command/issue.go | 8 +++++--- command/issue_test.go | 3 +-- command/pr.go | 10 +++++----- command/pr_test.go | 3 +-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/command/issue.go b/command/issue.go index 6caf81c12..b8f424311 100644 --- a/command/issue.go +++ b/command/issue.go @@ -108,13 +108,13 @@ func issueList(cmd *cobra.Command, args []string) error { return err } - fmt.Fprintf(colorableErr(cmd), "\nIssues for %s\n\n", ghrepo.FullName(*baseRepo)) - issues, err := api.IssueList(apiClient, *baseRepo, state, labels, assignee, limit) if err != nil { return err } + title := fmt.Sprintf("\n%s in %s\n\n", "%s", ghrepo.FullName(*baseRepo)) + if len(issues) == 0 { colorErr := colorableErr(cmd) // Send to stderr because otherwise when piping this command it would seem like the "no open issues" message is actually an issue msg := "There are no open issues" @@ -126,10 +126,12 @@ func issueList(cmd *cobra.Command, args []string) error { if userSetFlags { msg = "No issues match your search" } - printMessage(colorErr, msg) + fmt.Fprintf(colorErr, title, msg) return nil } + fmt.Fprintf(colorableErr(cmd), title, utils.Pluralize(len(issues), "issue")) + out := cmd.OutOrStdout() table := utils.NewTablePrinter(out) for _, issue := range issues { diff --git a/command/issue_test.go b/command/issue_test.go index c09de2c62..ba36101d4 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -142,9 +142,8 @@ func TestIssueList_withFlags(t *testing.T) { eq(t, output.String(), "") eq(t, output.Stderr(), ` -Issues for OWNER/REPO +No issues match your search in OWNER/REPO -No issues match your search `) bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body) diff --git a/command/pr.go b/command/pr.go index 917964d3b..999036607 100644 --- a/command/pr.go +++ b/command/pr.go @@ -135,7 +135,6 @@ func prList(cmd *cobra.Command, args []string) error { return err } - fmt.Fprintf(colorableErr(cmd), "\nPull requests for %s\n\n", ghrepo.FullName(*baseRepo)) limit, err := cmd.Flags().GetInt("limit") if err != nil { @@ -192,6 +191,8 @@ func prList(cmd *cobra.Command, args []string) error { return err } + title := fmt.Sprintf("\n%s in %s\n\n", "%s", ghrepo.FullName(*baseRepo)) + if len(prs) == 0 { colorErr := colorableErr(cmd) // Send to stderr because otherwise when piping this command it would seem like the "no open prs" message is acually a pr msg := "There are no open pull requests" @@ -203,13 +204,12 @@ func prList(cmd *cobra.Command, args []string) error { if userSetFlags { msg = "No pull requests match your search" } - printMessage(colorErr, msg) + fmt.Fprintf(colorErr, title, msg) return nil } - - prCountMsg := fmt.Sprintf("%d pull requests match your search\n", len(prs)) - printMessage(colorableErr(cmd), prCountMsg) + fmt.Fprintf(colorableErr(cmd), title, utils.Pluralize(len(prs), "pull request")) + table := utils.NewTablePrinter(cmd.OutOrStdout()) for _, pr := range prs { prNum := strconv.Itoa(pr.Number) diff --git a/command/pr_test.go b/command/pr_test.go index d621d447b..66c59d4d8 100644 --- a/command/pr_test.go +++ b/command/pr_test.go @@ -192,9 +192,8 @@ func TestPRList_filtering(t *testing.T) { eq(t, output.String(), "") eq(t, output.Stderr(), ` -Pull requests for OWNER/REPO +No pull requests match your search in OWNER/REPO -No pull requests match your search `) bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)