X Tutup
Skip to content

Commit b77c37d

Browse files
yanskunsamcoe
andauthored
feat: add job id, into run view suggest command (cli#5105)
* feat: add job id, into run view suggest command * fix: dry * fix: run id to job id * Change "a" to "the" when referencing a single job Co-authored-by: Sam Coe <samcoe@users.noreply.github.com>
1 parent 3a088e4 commit b77c37d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/cmd/run/view/view.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ func runView(opts *ViewOptions) error {
362362
fmt.Fprintln(out)
363363
if shared.IsFailureState(run.Conclusion) {
364364
fmt.Fprintf(out, "To see what failed, try: gh run view %d --log-failed\n", run.ID)
365+
} else if len(jobs) == 1 {
366+
fmt.Fprintf(out, "For more information about the job, try: gh run view --job=%d\n", jobs[0].ID)
365367
} else {
366-
fmt.Fprintln(out, "For more information about a job, try: gh run view --job=<job-id>")
368+
fmt.Fprintf(out, "For more information about a job, try: gh run view --job=<job-id>\n")
367369
}
368370
fmt.Fprintf(out, cs.Gray("View this run on GitHub: %s\n"), run.URL)
369371

pkg/cmd/run/view/view_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func TestViewRun(t *testing.T) {
207207
httpmock.REST("GET", "repos/OWNER/REPO/check-runs/10/annotations"),
208208
httpmock.JSONResponse([]shared.Annotation{}))
209209
},
210-
wantOut: "\n✓ trunk successful #2898 · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about a job, try: gh run view --job=<job-id>\nView this run on GitHub: https://github.com/runs/3\n",
210+
wantOut: "\n✓ trunk successful #2898 · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about the job, try: gh run view --job=10\nView this run on GitHub: https://github.com/runs/3\n",
211211
},
212212
{
213213
name: "exit status, failed run",
@@ -308,7 +308,7 @@ func TestViewRun(t *testing.T) {
308308
httpmock.REST("GET", "repos/OWNER/REPO/check-runs/10/annotations"),
309309
httpmock.JSONResponse([]shared.Annotation{}))
310310
},
311-
wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about a job, try: gh run view --job=<job-id>\nView this run on GitHub: https://github.com/runs/3\n",
311+
wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about the job, try: gh run view --job=10\nView this run on GitHub: https://github.com/runs/3\n",
312312
},
313313
{
314314
name: "verbose",
@@ -381,7 +381,7 @@ func TestViewRun(t *testing.T) {
381381
opts: &ViewOptions{
382382
Prompt: true,
383383
},
384-
wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about a job, try: gh run view --job=<job-id>\nView this run on GitHub: https://github.com/runs/3\n",
384+
wantOut: "\n✓ trunk successful · 3\nTriggered via push about 59 minutes ago\n\nJOBS\n✓ cool job in 4m34s (ID 10)\n\nFor more information about the job, try: gh run view --job=10\nView this run on GitHub: https://github.com/runs/3\n",
385385
},
386386
{
387387
name: "interactive with log",

0 commit comments

Comments
 (0)
X Tutup