Skip to content

Commit

Permalink
Merge pull request cli#8969 from sochotnicky/improve-rerun-docs
Browse files Browse the repository at this point in the history
Improve gh run rerun docs
  • Loading branch information
williammartin authored Apr 17, 2024
2 parents fd4f2c9 + 4aa18a9 commit 1319d2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 8 additions & 2 deletions pkg/cmd/run/rerun/rerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func NewCmdRerun(f *cmdutil.Factory, runF func(*RerunOptions) error) *cobra.Comm
API returning %[1]s404 NOT FOUND%[1]s. Instead, you can get the correct job IDs using the following command:
gh run view <run-id> --json jobs --jq '.jobs[] | {name, databaseId}'
You will need to use databaseId field for triggering job re-runs.
`, "`"),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -69,7 +71,11 @@ func NewCmdRerun(f *cmdutil.Factory, runF func(*RerunOptions) error) *cobra.Comm
}

if opts.RunID != "" && opts.JobID != "" {
return cmdutil.FlagErrorf("specify only one of `<run-id>` or `--job`")
opts.RunID = ""
if opts.IO.CanPrompt() {
cs := opts.IO.ColorScheme()
fmt.Fprintf(opts.IO.ErrOut, "%s both run and job IDs specified; ignoring run ID\n", cs.WarningIcon())
}
}

if runF != nil {
Expand All @@ -80,7 +86,7 @@ func NewCmdRerun(f *cmdutil.Factory, runF func(*RerunOptions) error) *cobra.Comm
}

cmd.Flags().BoolVar(&opts.OnlyFailed, "failed", false, "Rerun only failed jobs, including dependencies")
cmd.Flags().StringVarP(&opts.JobID, "job", "j", "", "Rerun a specific job from a run, including dependencies")
cmd.Flags().StringVarP(&opts.JobID, "job", "j", "", "Rerun a specific job ID from a run, including dependencies")
cmd.Flags().BoolVarP(&opts.Debug, "debug", "d", false, "Rerun with debug logging")

return cmd
Expand Down
11 changes: 7 additions & 4 deletions pkg/cmd/run/rerun/rerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ func TestNewCmdRerun(t *testing.T) {
},
},
{
name: "with args jobID and runID fails",
tty: true,
cli: "1234 --job 5678",
wantsErr: true,
name: "with args jobID and runID uses jobID",
tty: true,
cli: "1234 --job 5678",
wants: RerunOptions{
JobID: "5678",
RunID: "",
},
},
{
name: "with arg job with no ID fails",
Expand Down

0 comments on commit 1319d2c

Please sign in to comment.