Ignore run-id when providing also job for rerun

This makes the behaviour consistent with gh run view.
This commit is contained in:
Stanislav Ochotnický 2024-04-17 13:39:34 +02:00
parent fd4f2c9c1f
commit 40be4b366c
2 changed files with 12 additions and 5 deletions

View file

@ -69,7 +69,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 {

View file

@ -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",