Skip to content

Commit d0558fc

Browse files
authored
Merge pull request cli#13097 from Bahtya/fix-limit-final
Fix infinite loop in `gh release list --limit 0`
2 parents 5d3c2ba + 57b2477 commit d0558fc

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

pkg/cmd/release/list/list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
4444
// support `-R, --repo` override
4545
opts.BaseRepo = f.BaseRepo
4646

47+
if opts.LimitResults < 1 {
48+
return cmdutil.FlagErrorf("invalid limit: %v", opts.LimitResults)
49+
}
50+
4751
if runF != nil {
4852
return runF(opts)
4953
}

pkg/cmd/release/list/list_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ func Test_NewCmdList(t *testing.T) {
5858
Order: "desc",
5959
},
6060
},
61+
{
62+
name: "zero limit",
63+
args: "--limit 0",
64+
wantErr: "invalid limit: 0",
65+
},
6166
{
6267
name: "with order",
6368
args: "--order asc",

0 commit comments

Comments
 (0)