aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/code.gitea.io/sdk/gitea/version.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/code.gitea.io/sdk/gitea/version.go')
-rw-r--r--vendor/code.gitea.io/sdk/gitea/version.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/vendor/code.gitea.io/sdk/gitea/version.go b/vendor/code.gitea.io/sdk/gitea/version.go
index ed8a2ae5dd..1f41c77183 100644
--- a/vendor/code.gitea.io/sdk/gitea/version.go
+++ b/vendor/code.gitea.io/sdk/gitea/version.go
@@ -39,16 +39,39 @@ func (c *Client) CheckServerVersionConstraint(constraint string) error {
return nil
}
+// SetGiteaVersion configures the Client to assume the given version of the
+// Gitea server, instead of querying the server for it when initializing.
+// Use "" to skip all canonical ways in the SDK to check for versions
+func SetGiteaVersion(v string) ClientOption {
+ if v == "" {
+ return func(c *Client) error {
+ c.ignoreVersion = true
+ return nil
+ }
+ }
+ return func(c *Client) (err error) {
+ c.getVersionOnce.Do(func() {
+ c.serverVersion, err = version.NewVersion(v)
+ return
+ })
+ return
+ }
+}
+
// predefined versions only have to be parsed by library once
var (
version1_11_0, _ = version.NewVersion("1.11.0")
version1_12_0, _ = version.NewVersion("1.12.0")
version1_13_0, _ = version.NewVersion("1.13.0")
version1_14_0, _ = version.NewVersion("1.14.0")
+ version1_15_0, _ = version.NewVersion("1.15.0")
)
-// checkServerVersionGreaterThanOrEqual is internally used to speed up things and ignore issues with prerelease
+// checkServerVersionGreaterThanOrEqual is the canonical way in the SDK to check for versions for API compatibility reasons
func (c *Client) checkServerVersionGreaterThanOrEqual(v *version.Version) error {
+ if c.ignoreVersion {
+ return nil
+ }
if err := c.loadServerVersion(); err != nil {
return err
}