@@ -70,7 +70,6 @@ func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Comman
7070 # Exit non-zero if a run failed
7171 $ gh run view 0451 -e && echo "run pending or passed"
7272 ` ),
73- // TODO should exit status respect only a selected job if --job is passed?
7473 RunE : func (cmd * cobra.Command , args []string ) error {
7574 // support `-R, --repo` override
7675 opts .BaseRepo = f .BaseRepo
@@ -213,7 +212,7 @@ func runView(opts *ViewOptions) error {
213212 return fmt .Errorf ("failed to read log: %w" , err )
214213 }
215214
216- if opts .ExitStatus && shared .IsFailureState (run .Conclusion ) {
215+ if opts .ExitStatus && shared .IsFailureState (selectedJob .Conclusion ) {
217216 return cmdutil .SilentError
218217 }
219218
@@ -296,15 +295,18 @@ func runView(opts *ViewOptions) error {
296295 fmt .Fprintln (out , "For more information about a job, try: gh run view --job=<job-id>" )
297296 // TODO note about run view --log when that exists
298297 fmt .Fprintf (out , cs .Gray ("view this run on GitHub: %s\n " ), run .URL )
298+ if opts .ExitStatus && shared .IsFailureState (run .Conclusion ) {
299+ return cmdutil .SilentError
300+ }
299301 } else {
300302 fmt .Fprintln (out )
301303 // TODO this does not exist yet
302304 fmt .Fprintf (out , "To see the full job log, try: gh run view --log --job=%d\n " , selectedJob .ID )
303305 fmt .Fprintf (out , cs .Gray ("view this run on GitHub: %s\n " ), run .URL )
304- }
305306
306- if opts .ExitStatus && shared .IsFailureState (run .Conclusion ) {
307- return cmdutil .SilentError
307+ if opts .ExitStatus && shared .IsFailureState (selectedJob .Conclusion ) {
308+ return cmdutil .SilentError
309+ }
308310 }
309311
310312 return nil
0 commit comments