From 3943a8bb1fca0c2356f145e381e2dc4bf179120c Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Fri, 28 May 2021 18:53:31 +0200 Subject: [PATCH 1/4] Update PR tty view formatting and its tests --- pkg/cmd/pr/view/view.go | 2 +- pkg/cmd/pr/view/view_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/cmd/pr/view/view.go b/pkg/cmd/pr/view/view.go index 91087d74b..a37568741 100644 --- a/pkg/cmd/pr/view/view.go +++ b/pkg/cmd/pr/view/view.go @@ -170,7 +170,7 @@ func printHumanPrPreview(opts *ViewOptions, pr *api.PullRequest) error { cs := opts.IO.ColorScheme() // Header (Title and State) - fmt.Fprintln(out, cs.Bold(pr.Title)) + fmt.Fprintf(out, "%s #%d", cs.Bold(pr.Title), pr.Number) fmt.Fprintf(out, "%s • %s wants to merge %s into %s from %s • %s %s \n", shared.StateTitleWithColor(cs, *pr), diff --git a/pkg/cmd/pr/view/view_test.go b/pkg/cmd/pr/view/view_test.go index 78d588f1e..82a4a4e95 100644 --- a/pkg/cmd/pr/view/view_test.go +++ b/pkg/cmd/pr/view/view_test.go @@ -350,7 +350,7 @@ func TestPRView_Preview(t *testing.T) { "PullRequestByNumber": "./fixtures/prViewPreview.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Open.*nobody wants to merge 12 commits into master from blueberries.+100.-10`, `blueberries taste good`, `View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`, @@ -363,7 +363,7 @@ func TestPRView_Preview(t *testing.T) { "PullRequestByNumber": "./fixtures/prViewPreviewWithMetadataByNumber.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Open.*nobody wants to merge 12 commits into master from blueberries.+100.-10`, `Reviewers:.*1 \(.*Requested.*\)\n`, `Assignees:.*marseilles, monaco\n`, @@ -382,7 +382,7 @@ func TestPRView_Preview(t *testing.T) { "ReviewsForPullRequest": "./fixtures/prViewPreviewManyReviews.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Reviewers:.*DEF \(.*Commented.*\), def \(.*Changes requested.*\), ghost \(.*Approved.*\), hubot \(Commented\), xyz \(.*Approved.*\), 123 \(.*Requested.*\), Team 1 \(.*Requested.*\), abc \(.*Requested.*\)\n`, `blueberries taste good`, `View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`, @@ -395,7 +395,7 @@ func TestPRView_Preview(t *testing.T) { "PullRequestByNumber": "./fixtures/prViewPreviewClosedState.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Closed.*nobody wants to merge 12 commits into master from blueberries.+100.-10`, `blueberries taste good`, `View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`, @@ -408,7 +408,7 @@ func TestPRView_Preview(t *testing.T) { "PullRequestByNumber": "./fixtures/prViewPreviewMergedState.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Merged.*nobody wants to merge 12 commits into master from blueberries.+100.-10`, `blueberries taste good`, `View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`, @@ -421,7 +421,7 @@ func TestPRView_Preview(t *testing.T) { "PullRequestByNumber": "./fixtures/prViewPreviewDraftState.json", }, expectedOutputs: []string{ - `Blueberries are from a fork`, + `Blueberries are from a fork #12`, `Draft.*nobody wants to merge 12 commits into master from blueberries.+100.-10`, `blueberries taste good`, `View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`, @@ -501,7 +501,7 @@ func TestPRView_tty_Comments(t *testing.T) { "ReviewsForPullRequest": "./fixtures/prViewPreviewReviews.json", }, expectedOutputs: []string{ - `some title`, + `some title #12`, `1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f}`, `some body`, `———————— Not showing 9 comments ————————`, @@ -521,7 +521,7 @@ func TestPRView_tty_Comments(t *testing.T) { "CommentsForPullRequest": "./fixtures/prViewPreviewFullComments.json", }, expectedOutputs: []string{ - `some title`, + `some title #12`, `some body`, `monalisa • Jan 1, 2020 • Edited`, `1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f} • 4 \x{1f389} • 5 \x{1f604} • 6 \x{1f680} • 7 \x{1f44e} • 8 \x{1f44d}`, From 979ec9298d7d88f84ac84b1bf753a4b296262923 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Sat, 29 May 2021 04:43:34 +0200 Subject: [PATCH 2/4] Update issue tty view formatting and its tests --- pkg/cmd/issue/view/view.go | 2 +- pkg/cmd/issue/view/view_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/cmd/issue/view/view.go b/pkg/cmd/issue/view/view.go index 78be7df09..21fa76001 100644 --- a/pkg/cmd/issue/view/view.go +++ b/pkg/cmd/issue/view/view.go @@ -172,7 +172,7 @@ func printHumanIssuePreview(opts *ViewOptions, issue *api.Issue) error { cs := opts.IO.ColorScheme() // Header (Title and State) - fmt.Fprintln(out, cs.Bold(issue.Title)) + fmt.Fprintf(out, "%s #%d", cs.Bold(issue.Title), issue.Number) fmt.Fprintf(out, "%s • %s opened %s • %s\n", issueStateTitleWithColor(cs, issue.State), diff --git a/pkg/cmd/issue/view/view_test.go b/pkg/cmd/issue/view/view_test.go index dc5c5dfb5..f10ab1677 100644 --- a/pkg/cmd/issue/view/view_test.go +++ b/pkg/cmd/issue/view/view_test.go @@ -178,7 +178,7 @@ func TestIssueView_tty_Preview(t *testing.T) { "Open issue without metadata": { fixture: "./fixtures/issueView_preview.json", expectedOutputs: []string{ - `ix of coins`, + `ix of coins #123`, `Open.*marseilles opened about 9 years ago.*9 comments`, `bold story`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, @@ -187,7 +187,7 @@ func TestIssueView_tty_Preview(t *testing.T) { "Open issue with metadata": { fixture: "./fixtures/issueView_previewWithMetadata.json", expectedOutputs: []string{ - `ix of coins`, + `ix of coins #123`, `Open.*marseilles opened about 9 years ago.*9 comments`, `8 \x{1f615} • 7 \x{1f440} • 6 \x{2764}\x{fe0f} • 5 \x{1f389} • 4 \x{1f604} • 3 \x{1f680} • 2 \x{1f44e} • 1 \x{1f44d}`, `Assignees:.*marseilles, monaco\n`, @@ -201,7 +201,7 @@ func TestIssueView_tty_Preview(t *testing.T) { "Open issue with empty body": { fixture: "./fixtures/issueView_previewWithEmptyBody.json", expectedOutputs: []string{ - `ix of coins`, + `ix of coins #123`, `Open.*marseilles opened about 9 years ago.*9 comments`, `No description provided`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, @@ -210,7 +210,7 @@ func TestIssueView_tty_Preview(t *testing.T) { "Closed issue": { fixture: "./fixtures/issueView_previewClosedState.json", expectedOutputs: []string{ - `ix of coins`, + `ix of coins #123`, `Closed.*marseilles opened about 9 years ago.*9 comments`, `bold story`, `View this issue on GitHub: https://github.com/OWNER/REPO/issues/123`, @@ -310,7 +310,7 @@ func TestIssueView_tty_Comments(t *testing.T) { "IssueByNumber": "./fixtures/issueView_previewSingleComment.json", }, expectedOutputs: []string{ - `some title`, + `some title #123`, `some body`, `———————— Not showing 5 comments ————————`, `marseilles \(Collaborator\) • Jan 1, 2020 • Newest comment`, @@ -326,7 +326,7 @@ func TestIssueView_tty_Comments(t *testing.T) { "CommentsForIssue": "./fixtures/issueView_previewFullComments.json", }, expectedOutputs: []string{ - `some title`, + `some title #123`, `some body`, `monalisa • Jan 1, 2020 • Edited`, `1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f} • 4 \x{1f389} • 5 \x{1f604} • 6 \x{1f680} • 7 \x{1f44e} • 8 \x{1f44d}`, From 42333bb2d1cb11a3d224d11aa1c15bf298382ad2 Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Sat, 29 May 2021 04:43:58 +0200 Subject: [PATCH 3/4] Update issue non-tty view formatting and its tests --- pkg/cmd/issue/view/view.go | 1 + pkg/cmd/issue/view/view_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/cmd/issue/view/view.go b/pkg/cmd/issue/view/view.go index 21fa76001..87c8e3143 100644 --- a/pkg/cmd/issue/view/view.go +++ b/pkg/cmd/issue/view/view.go @@ -160,6 +160,7 @@ func printRawIssuePreview(out io.Writer, issue *api.Issue) error { milestoneTitle = issue.Milestone.Title } fmt.Fprintf(out, "milestone:\t%s\n", milestoneTitle) + fmt.Fprintf(out, "number:\t%d\n", issue.Number) fmt.Fprintln(out, "--") fmt.Fprintln(out, issue.Body) return nil diff --git a/pkg/cmd/issue/view/view_test.go b/pkg/cmd/issue/view/view_test.go index f10ab1677..01ec824fc 100644 --- a/pkg/cmd/issue/view/view_test.go +++ b/pkg/cmd/issue/view/view_test.go @@ -112,6 +112,7 @@ func TestIssueView_nontty_Preview(t *testing.T) { `comments:\t9`, `author:\tmarseilles`, `assignees:`, + `number:\t123\n`, `\*\*bold story\*\*`, }, }, @@ -126,6 +127,7 @@ func TestIssueView_nontty_Preview(t *testing.T) { `labels:\tone, two, three, four, five`, `projects:\tProject 1 \(column A\), Project 2 \(column B\), Project 3 \(column C\), Project 4 \(Awaiting triage\)\n`, `milestone:\tuluru\n`, + `number:\t123\n`, `\*\*bold story\*\*`, }, }, @@ -136,6 +138,7 @@ func TestIssueView_nontty_Preview(t *testing.T) { `state:\tOPEN`, `author:\tmarseilles`, `labels:\ttarot`, + `number:\t123\n`, }, }, "Closed issue": { @@ -146,6 +149,7 @@ func TestIssueView_nontty_Preview(t *testing.T) { `\*\*bold story\*\*`, `author:\tmarseilles`, `labels:\ttarot`, + `number:\t123\n`, `\*\*bold story\*\*`, }, }, @@ -386,6 +390,7 @@ func TestIssueView_nontty_Comments(t *testing.T) { `state:\tOPEN`, `author:\tmarseilles`, `comments:\t6`, + `number:\t123`, `some body`, }, }, From 184149b8440ec013a10ea90ce71879017c0f453a Mon Sep 17 00:00:00 2001 From: jack1142 <6032823+jack1142@users.noreply.github.com> Date: Tue, 1 Jun 2021 23:53:58 +0200 Subject: [PATCH 4/4] Add missing new line --- pkg/cmd/issue/view/view.go | 2 +- pkg/cmd/pr/view/view.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/issue/view/view.go b/pkg/cmd/issue/view/view.go index 87c8e3143..d4f96bbd8 100644 --- a/pkg/cmd/issue/view/view.go +++ b/pkg/cmd/issue/view/view.go @@ -173,7 +173,7 @@ func printHumanIssuePreview(opts *ViewOptions, issue *api.Issue) error { cs := opts.IO.ColorScheme() // Header (Title and State) - fmt.Fprintf(out, "%s #%d", cs.Bold(issue.Title), issue.Number) + fmt.Fprintf(out, "%s #%d\n", cs.Bold(issue.Title), issue.Number) fmt.Fprintf(out, "%s • %s opened %s • %s\n", issueStateTitleWithColor(cs, issue.State), diff --git a/pkg/cmd/pr/view/view.go b/pkg/cmd/pr/view/view.go index a37568741..c733909c5 100644 --- a/pkg/cmd/pr/view/view.go +++ b/pkg/cmd/pr/view/view.go @@ -170,7 +170,7 @@ func printHumanPrPreview(opts *ViewOptions, pr *api.PullRequest) error { cs := opts.IO.ColorScheme() // Header (Title and State) - fmt.Fprintf(out, "%s #%d", cs.Bold(pr.Title), pr.Number) + fmt.Fprintf(out, "%s #%d\n", cs.Bold(pr.Title), pr.Number) fmt.Fprintf(out, "%s • %s wants to merge %s into %s from %s • %s %s \n", shared.StateTitleWithColor(cs, *pr),