Allow gitea dev version (#914)

* update gitea sdk to latest
* As before try to autodetect gitea version, if this does not work, assume it's latest version (v1.17.0 atm)
This commit is contained in:
6543
2022-05-14 17:34:40 +02:00
committed by GitHub
parent c350af645b
commit d06dfc86b4
28 changed files with 358 additions and 163 deletions

View File

@@ -9,12 +9,13 @@ import (
"net/url"
)
const defaultPageSize = 10
const maxPageSize = 50
// ListOptions options for using Gitea's API pagination
type ListOptions struct {
Page int
// Setting Page to -1 disables pagination on endpoints that support it.
// Page numbering starts at 1.
Page int
// The default value depends on the server config DEFAULT_PAGING_NUM
// The highest valid value depends on the server config MAX_RESPONSE_ITEMS
PageSize int
}
@@ -26,8 +27,9 @@ func (o ListOptions) getURLQuery() url.Values {
return query
}
// setDefaults set default pagination options if none or wrong are set
// if you set -1 as page it will set all to 0
// setDefaults applies default pagination options.
// If .Page is set to -1, it will disable pagination.
// WARNING: This function is not idempotent, make sure to never call this method twice!
func (o *ListOptions) setDefaults() {
if o.Page < 0 {
o.Page, o.PageSize = 0, 0
@@ -35,8 +37,4 @@ func (o *ListOptions) setDefaults() {
} else if o.Page == 0 {
o.Page = 1
}
if o.PageSize < 0 || o.PageSize > maxPageSize {
o.PageSize = defaultPageSize
}
}