From 7de882b74498d4d7ee8023df275db1d16ca09a65 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 31 Mar 2021 04:28:44 +0800 Subject: [PATCH] ListFunctions: option to disable pagination (#509) the sdk enforce pagination, but most list endpoints dont require it ... close #507 fully Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/509 Reviewed-by: Andrew Thornton Reviewed-by: John Olheiser Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de> --- gitea/list_options.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gitea/list_options.go b/gitea/list_options.go index 12b7e8b..6f3ffb2 100644 --- a/gitea/list_options.go +++ b/gitea/list_options.go @@ -27,8 +27,12 @@ func (o ListOptions) getURLQuery() url.Values { } // setDefaults set default pagination options if none or wrong are set +// if you set -1 as page it will set all to 0 func (o *ListOptions) setDefaults() { - if o.Page < 1 { + if o.Page < 0 { + o.Page, o.PageSize = 0, 0 + return + } else if o.Page == 0 { o.Page = 1 }