X Tutup
Skip to content

Commit 3943a8b

Browse files
committed
Update PR tty view formatting and its tests
1 parent e160dd3 commit 3943a8b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pkg/cmd/pr/view/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func printHumanPrPreview(opts *ViewOptions, pr *api.PullRequest) error {
170170
cs := opts.IO.ColorScheme()
171171

172172
// Header (Title and State)
173-
fmt.Fprintln(out, cs.Bold(pr.Title))
173+
fmt.Fprintf(out, "%s #%d", cs.Bold(pr.Title), pr.Number)
174174
fmt.Fprintf(out,
175175
"%s • %s wants to merge %s into %s from %s • %s %s \n",
176176
shared.StateTitleWithColor(cs, *pr),

pkg/cmd/pr/view/view_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func TestPRView_Preview(t *testing.T) {
350350
"PullRequestByNumber": "./fixtures/prViewPreview.json",
351351
},
352352
expectedOutputs: []string{
353-
`Blueberries are from a fork`,
353+
`Blueberries are from a fork #12`,
354354
`Open.*nobody wants to merge 12 commits into master from blueberries.+100.-10`,
355355
`blueberries taste good`,
356356
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
@@ -363,7 +363,7 @@ func TestPRView_Preview(t *testing.T) {
363363
"PullRequestByNumber": "./fixtures/prViewPreviewWithMetadataByNumber.json",
364364
},
365365
expectedOutputs: []string{
366-
`Blueberries are from a fork`,
366+
`Blueberries are from a fork #12`,
367367
`Open.*nobody wants to merge 12 commits into master from blueberries.+100.-10`,
368368
`Reviewers:.*1 \(.*Requested.*\)\n`,
369369
`Assignees:.*marseilles, monaco\n`,
@@ -382,7 +382,7 @@ func TestPRView_Preview(t *testing.T) {
382382
"ReviewsForPullRequest": "./fixtures/prViewPreviewManyReviews.json",
383383
},
384384
expectedOutputs: []string{
385-
`Blueberries are from a fork`,
385+
`Blueberries are from a fork #12`,
386386
`Reviewers:.*DEF \(.*Commented.*\), def \(.*Changes requested.*\), ghost \(.*Approved.*\), hubot \(Commented\), xyz \(.*Approved.*\), 123 \(.*Requested.*\), Team 1 \(.*Requested.*\), abc \(.*Requested.*\)\n`,
387387
`blueberries taste good`,
388388
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
@@ -395,7 +395,7 @@ func TestPRView_Preview(t *testing.T) {
395395
"PullRequestByNumber": "./fixtures/prViewPreviewClosedState.json",
396396
},
397397
expectedOutputs: []string{
398-
`Blueberries are from a fork`,
398+
`Blueberries are from a fork #12`,
399399
`Closed.*nobody wants to merge 12 commits into master from blueberries.+100.-10`,
400400
`blueberries taste good`,
401401
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
@@ -408,7 +408,7 @@ func TestPRView_Preview(t *testing.T) {
408408
"PullRequestByNumber": "./fixtures/prViewPreviewMergedState.json",
409409
},
410410
expectedOutputs: []string{
411-
`Blueberries are from a fork`,
411+
`Blueberries are from a fork #12`,
412412
`Merged.*nobody wants to merge 12 commits into master from blueberries.+100.-10`,
413413
`blueberries taste good`,
414414
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
@@ -421,7 +421,7 @@ func TestPRView_Preview(t *testing.T) {
421421
"PullRequestByNumber": "./fixtures/prViewPreviewDraftState.json",
422422
},
423423
expectedOutputs: []string{
424-
`Blueberries are from a fork`,
424+
`Blueberries are from a fork #12`,
425425
`Draft.*nobody wants to merge 12 commits into master from blueberries.+100.-10`,
426426
`blueberries taste good`,
427427
`View this pull request on GitHub: https://github.com/OWNER/REPO/pull/12`,
@@ -501,7 +501,7 @@ func TestPRView_tty_Comments(t *testing.T) {
501501
"ReviewsForPullRequest": "./fixtures/prViewPreviewReviews.json",
502502
},
503503
expectedOutputs: []string{
504-
`some title`,
504+
`some title #12`,
505505
`1 \x{1f615} • 2 \x{1f440} • 3 \x{2764}\x{fe0f}`,
506506
`some body`,
507507
`———————— Not showing 9 comments ————————`,
@@ -521,7 +521,7 @@ func TestPRView_tty_Comments(t *testing.T) {
521521
"CommentsForPullRequest": "./fixtures/prViewPreviewFullComments.json",
522522
},
523523
expectedOutputs: []string{
524-
`some title`,
524+
`some title #12`,
525525
`some body`,
526526
`monalisa • Jan 1, 2020 • Edited`,
527527
`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}`,

0 commit comments

Comments
 (0)
X Tutup