Fix infinite loop in 'gh release list --limit 0'

Other list subcommands correctly reject --limit 0 but 'release list'
does not validate the limit, causing an infinite loop.

Add validation consistent with other subcommands and a test.

Closes #13078
This commit is contained in:
bahtya 2026-04-04 18:12:33 +08:00
parent 5d3c2ba569
commit 57b2477752
2 changed files with 9 additions and 0 deletions

View file

@ -44,6 +44,10 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
// support `-R, --repo` override
opts.BaseRepo = f.BaseRepo
if opts.LimitResults < 1 {
return cmdutil.FlagErrorf("invalid limit: %v", opts.LimitResults)
}
if runF != nil {
return runF(opts)
}

View file

@ -58,6 +58,11 @@ func Test_NewCmdList(t *testing.T) {
Order: "desc",
},
},
{
name: "zero limit",
args: "--limit 0",
wantErr: "invalid limit: 0",
},
{
name: "with order",
args: "--order asc",