From e6fbba3f80c4fbd2bb1990fa58966961a37636f3 Mon Sep 17 00:00:00 2001 From: Norwin Date: Sat, 14 Nov 2020 18:31:01 +0800 Subject: [PATCH] update code.gitea.io/sdk/gitea to support prerelease (#252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update code.gitea.io/sdk/gitea to prerelease Co-authored-by: Norwin Roosen Reviewed-on: https://gitea.com/gitea/tea/pulls/252 Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: 赵智超 <1012112796@qq.com> Reviewed-by: Lunny Xiao Co-Authored-By: Norwin Co-Committed-By: Norwin --- go.mod | 3 +- go.sum | 6 +-- vendor/code.gitea.io/sdk/gitea/admin_cron.go | 4 +- vendor/code.gitea.io/sdk/gitea/client.go | 2 +- vendor/code.gitea.io/sdk/gitea/go.mod | 2 +- vendor/code.gitea.io/sdk/gitea/issue.go | 6 +-- .../code.gitea.io/sdk/gitea/issue_comment.go | 2 +- vendor/code.gitea.io/sdk/gitea/issue_label.go | 2 +- .../code.gitea.io/sdk/gitea/issue_reaction.go | 12 +++--- .../sdk/gitea/issue_subscription.go | 8 ++-- .../sdk/gitea/issue_tracked_time.go | 14 +++---- .../code.gitea.io/sdk/gitea/notifications.go | 24 ++++++----- vendor/code.gitea.io/sdk/gitea/oauth2.go | 10 ++--- vendor/code.gitea.io/sdk/gitea/pull.go | 4 +- vendor/code.gitea.io/sdk/gitea/pull_review.go | 12 +++--- vendor/code.gitea.io/sdk/gitea/release.go | 2 +- vendor/code.gitea.io/sdk/gitea/repo.go | 40 +++++++++++++++++-- vendor/code.gitea.io/sdk/gitea/repo_branch.go | 4 +- .../sdk/gitea/repo_branch_protection.go | 10 ++--- vendor/code.gitea.io/sdk/gitea/repo_commit.go | 5 ++- vendor/code.gitea.io/sdk/gitea/repo_file.go | 2 +- .../code.gitea.io/sdk/gitea/repo_migrate.go | 19 ++++++--- .../code.gitea.io/sdk/gitea/repo_transfer.go | 2 +- vendor/code.gitea.io/sdk/gitea/settings.go | 8 ++-- vendor/code.gitea.io/sdk/gitea/version.go | 26 ++++++++++++ vendor/modules.txt | 2 +- 26 files changed, 151 insertions(+), 80 deletions(-) diff --git a/go.mod b/go.mod index f3694a6..d362a26 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( code.gitea.io/gitea-vet v0.2.1 - code.gitea.io/sdk/gitea v0.13.1 + code.gitea.io/sdk/gitea v0.13.2-0.20201112213603-e323ee0bc434 github.com/AlecAivazis/survey/v2 v2.2.2 github.com/Microsoft/go-winio v0.4.15 // indirect github.com/adrg/xdg v0.2.2 @@ -14,7 +14,6 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/dlclark/regexp2 v1.4.0 // indirect github.com/go-git/go-git/v5 v5.2.0 - github.com/hashicorp/go-version v1.2.1 // indirect github.com/imdario/mergo v0.3.11 // indirect github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect github.com/mattn/go-colorable v0.1.8 // indirect diff --git a/go.sum b/go.sum index 2933b8c..8d8a94a 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ code.gitea.io/gitea-vet v0.2.1 h1:b30by7+3SkmiftK0RjuXqFvZg2q4p68uoPGuxhzBN0s= code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE= -code.gitea.io/sdk/gitea v0.13.1 h1:Y7bpH2iO6Q0KhhMJfjP/LZ0AmiYITeRQlCD8b0oYqhk= -code.gitea.io/sdk/gitea v0.13.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY= +code.gitea.io/sdk/gitea v0.13.2-0.20201112213603-e323ee0bc434 h1:koxDF6qb81P1spPf48UJBCiuWlc3crd1+uUEOyFVolY= +code.gitea.io/sdk/gitea v0.13.2-0.20201112213603-e323ee0bc434/go.mod h1:lee2y8LeV3kQb2iK+hHlMqoadL4bp27QOkOV/hawLKg= github.com/AlecAivazis/survey/v2 v2.2.2 h1:1I4qBrNsHQE+91tQCqVlfrKe9DEL65949d1oKZWVELY= github.com/AlecAivazis/survey/v2 v2.2.2/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -72,8 +72,6 @@ github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gm github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= -github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= diff --git a/vendor/code.gitea.io/sdk/gitea/admin_cron.go b/vendor/code.gitea.io/sdk/gitea/admin_cron.go index 72f77e5..99006b6 100644 --- a/vendor/code.gitea.io/sdk/gitea/admin_cron.go +++ b/vendor/code.gitea.io/sdk/gitea/admin_cron.go @@ -25,7 +25,7 @@ type ListCronTaskOptions struct { // ListCronTasks list available cron tasks func (c *Client) ListCronTasks(opt ListCronTaskOptions) ([]*CronTask, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } opt.setDefaults() @@ -36,7 +36,7 @@ func (c *Client) ListCronTasks(opt ListCronTaskOptions) ([]*CronTask, *Response, // RunCronTasks run a cron task func (c *Client) RunCronTasks(task string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, err } _, resp, err := c.getResponse("POST", fmt.Sprintf("/admin/cron/%s", task), jsonHeader, nil) diff --git a/vendor/code.gitea.io/sdk/gitea/client.go b/vendor/code.gitea.io/sdk/gitea/client.go index ca5ee35..e08bc9e 100644 --- a/vendor/code.gitea.io/sdk/gitea/client.go +++ b/vendor/code.gitea.io/sdk/gitea/client.go @@ -56,7 +56,7 @@ func NewClient(url string, options ...func(*Client)) (*Client, error) { for _, opt := range options { opt(client) } - if err := client.CheckServerVersionConstraint(">=1.10"); err != nil { + if err := client.checkServerVersionGreaterThanOrEqual(version1_10_0); err != nil { return nil, err } return client, nil diff --git a/vendor/code.gitea.io/sdk/gitea/go.mod b/vendor/code.gitea.io/sdk/gitea/go.mod index 7b0d75f..fe2a46a 100644 --- a/vendor/code.gitea.io/sdk/gitea/go.mod +++ b/vendor/code.gitea.io/sdk/gitea/go.mod @@ -3,6 +3,6 @@ module code.gitea.io/sdk/gitea go 1.12 require ( - github.com/hashicorp/go-version v1.2.0 + github.com/hashicorp/go-version v1.2.1 github.com/stretchr/testify v1.4.0 ) diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/vendor/code.gitea.io/sdk/gitea/issue.go index 1b09b3f..7eef447 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/vendor/code.gitea.io/sdk/gitea/issue.go @@ -121,7 +121,7 @@ func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, *Response, error) { link, _ := url.Parse("/repos/issues/search") link.RawQuery = opt.QueryEncode() resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues) - if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil { + if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil { for i := 0; i < len(issues); i++ { if issues[i].Repository != nil { issues[i].Repository.Owner = strings.Split(issues[i].Repository.FullName, "/")[0] @@ -139,7 +139,7 @@ func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Iss link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/issues", owner, repo)) link.RawQuery = opt.QueryEncode() resp, err := c.getParsedResponse("GET", link.String(), jsonHeader, nil, &issues) - if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil { + if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil { for i := 0; i < len(issues); i++ { if issues[i].Repository != nil { issues[i].Repository.Owner = strings.Split(issues[i].Repository.FullName, "/")[0] @@ -153,7 +153,7 @@ func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Iss func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, *Response, error) { issue := new(Issue) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue) - if e := c.CheckServerVersionConstraint(">=1.12.0"); e != nil && issue.Repository != nil { + if e := c.checkServerVersionGreaterThanOrEqual(version1_12_0); e != nil && issue.Repository != nil { issue.Repository.Owner = strings.Split(issue.Repository.FullName, "/")[0] } return issue, resp, err diff --git a/vendor/code.gitea.io/sdk/gitea/issue_comment.go b/vendor/code.gitea.io/sdk/gitea/issue_comment.go index 50b3532..4eff850 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_comment.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_comment.go @@ -68,7 +68,7 @@ func (c *Client) ListRepoIssueComments(owner, repo string, opt ListIssueCommentO // GetIssueComment get a comment for a given repo by id. func (c *Client) GetIssueComment(owner, repo string, id int64) (*Comment, *Response, error) { comment := new(Comment) - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return comment, nil, err } resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments/%d", owner, repo, id), nil, nil, &comment) diff --git a/vendor/code.gitea.io/sdk/gitea/issue_label.go b/vendor/code.gitea.io/sdk/gitea/issue_label.go index 1eb3c74..b664dac 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_label.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_label.go @@ -71,7 +71,7 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, return nil, nil, err } if len(opt.Color) == 6 { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { opt.Color = "#" + opt.Color } } diff --git a/vendor/code.gitea.io/sdk/gitea/issue_reaction.go b/vendor/code.gitea.io/sdk/gitea/issue_reaction.go index a70209a..4ec203c 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_reaction.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_reaction.go @@ -20,7 +20,7 @@ type Reaction struct { // GetIssueReactions get a list reactions of an issue func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } reactions := make([]*Reaction, 0, 10) @@ -30,7 +30,7 @@ func (c *Client) GetIssueReactions(owner, repo string, index int64) ([]*Reaction // GetIssueCommentReactions get a list of reactions from a comment of an issue func (c *Client) GetIssueCommentReactions(owner, repo string, commentID int64) ([]*Reaction, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } reactions := make([]*Reaction, 0, 10) @@ -45,7 +45,7 @@ type editReactionOption struct { // PostIssueReaction add a reaction to an issue func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction string) (*Reaction, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } reactionResponse := new(Reaction) @@ -61,7 +61,7 @@ func (c *Client) PostIssueReaction(owner, repo string, index int64, reaction str // DeleteIssueReaction remove a reaction from an issue func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } body, err := json.Marshal(&editReactionOption{Reaction: reaction}) @@ -74,7 +74,7 @@ func (c *Client) DeleteIssueReaction(owner, repo string, index int64, reaction s // PostIssueCommentReaction add a reaction to a comment of an issue func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Reaction, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } reactionResponse := new(Reaction) @@ -90,7 +90,7 @@ func (c *Client) PostIssueCommentReaction(owner, repo string, commentID int64, r // DeleteIssueCommentReaction remove a reaction from a comment of an issue func (c *Client) DeleteIssueCommentReaction(owner, repo string, commentID int64, reaction string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } body, err := json.Marshal(&editReactionOption{Reaction: reaction}) diff --git a/vendor/code.gitea.io/sdk/gitea/issue_subscription.go b/vendor/code.gitea.io/sdk/gitea/issue_subscription.go index 52e67ed..0af4228 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_subscription.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_subscription.go @@ -11,7 +11,7 @@ import ( // GetIssueSubscribers get list of users who subscribed on an issue func (c *Client) GetIssueSubscribers(owner, repo string, index int64) ([]*User, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } subscribers := make([]*User, 0, 10) @@ -21,7 +21,7 @@ func (c *Client) GetIssueSubscribers(owner, repo string, index int64) ([]*User, // AddIssueSubscription Subscribe user to issue func (c *Client) AddIssueSubscription(owner, repo string, index int64, user string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } status, resp, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) @@ -39,7 +39,7 @@ func (c *Client) AddIssueSubscription(owner, repo string, index int64, user stri // DeleteIssueSubscription unsubscribe user from issue func (c *Client) DeleteIssueSubscription(owner, repo string, index int64, user string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) @@ -57,7 +57,7 @@ func (c *Client) DeleteIssueSubscription(owner, repo string, index int64, user s // CheckIssueSubscription check if current user is subscribed to an issue func (c *Client) CheckIssueSubscription(owner, repo string, index int64) (*WatchInfo, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } wi := new(WatchInfo) diff --git a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go index 481c831..9a9922e 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go @@ -27,7 +27,7 @@ type TrackedTime struct { // GetUserTrackedTimes list tracked times of a user func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } times := make([]*TrackedTime, 0, 10) @@ -37,7 +37,7 @@ func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, // GetRepoTrackedTimes list tracked times of a repository func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } times := make([]*TrackedTime, 0, 10) @@ -47,7 +47,7 @@ func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, *Respo // GetMyTrackedTimes list tracked times of the current user func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } times := make([]*TrackedTime, 0, 10) @@ -75,7 +75,7 @@ func (opt AddTimeOption) Validate() error { // AddTime adds time to issue with the given index func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } if err := opt.Validate(); err != nil { @@ -99,7 +99,7 @@ type ListTrackedTimesOptions struct { // ListTrackedTimes list tracked times of a single issue for a given repository func (c *Client) ListTrackedTimes(owner, repo string, index int64, opt ListTrackedTimesOptions) ([]*TrackedTime, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, nil, err } opt.setDefaults() @@ -110,7 +110,7 @@ func (c *Client) ListTrackedTimes(owner, repo string, index int64, opt ListTrack // ResetIssueTime reset tracked time of a single issue for a given repository func (c *Client) ResetIssueTime(owner, repo string, index int64) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil) @@ -119,7 +119,7 @@ func (c *Client) ResetIssueTime(owner, repo string, index int64) (*Response, err // DeleteTime delete a specific tracked time by id of a single issue for a given repository func (c *Client) DeleteTime(owner, repo string, index, timeID int64) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.11.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_11_0); err != nil { return nil, err } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), nil, nil) diff --git a/vendor/code.gitea.io/sdk/gitea/notifications.go b/vendor/code.gitea.io/sdk/gitea/notifications.go index 515a0d4..30b6b6d 100644 --- a/vendor/code.gitea.io/sdk/gitea/notifications.go +++ b/vendor/code.gitea.io/sdk/gitea/notifications.go @@ -8,6 +8,12 @@ import ( "fmt" "net/url" "time" + + "github.com/hashicorp/go-version" +) + +var ( + version1_12_3, _ = version.NewVersion("1.12.3") ) // NotificationThread expose Notification on API @@ -75,7 +81,7 @@ func (opt *ListNotificationOptions) QueryEncode() string { // Validate the CreateUserOption struct func (opt ListNotificationOptions) Validate(c *Client) error { if len(opt.Status) != 0 { - return c.CheckServerVersionConstraint(">=1.12.3") + return c.checkServerVersionGreaterThanOrEqual(version1_12_3) } return nil } @@ -98,14 +104,14 @@ func (opt *MarkNotificationOptions) QueryEncode() string { // Validate the CreateUserOption struct func (opt MarkNotificationOptions) Validate(c *Client) error { if len(opt.Status) != 0 || len(opt.ToStatus) != 0 { - return c.CheckServerVersionConstraint(">=1.12.3") + return c.checkServerVersionGreaterThanOrEqual(version1_12_3) } return nil } // CheckNotifications list users's notification threads func (c *Client) CheckNotifications() (int64, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return 0, nil, err } new := struct { @@ -118,7 +124,7 @@ func (c *Client) CheckNotifications() (int64, *Response, error) { // GetNotification get notification thread by ID func (c *Client) GetNotification(id int64) (*NotificationThread, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } thread := new(NotificationThread) @@ -129,7 +135,7 @@ func (c *Client) GetNotification(id int64) (*NotificationThread, *Response, erro // ReadNotification mark notification thread as read by ID // It optionally takes a second argument if status has to be set other than 'read' func (c *Client) ReadNotification(id int64, status ...NotifyStatus) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } link := fmt.Sprintf("/notifications/threads/%d", id) @@ -142,7 +148,7 @@ func (c *Client) ReadNotification(id int64, status ...NotifyStatus) (*Response, // ListNotifications list users's notification threads func (c *Client) ListNotifications(opt ListNotificationOptions) ([]*NotificationThread, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } if err := opt.Validate(c); err != nil { @@ -157,7 +163,7 @@ func (c *Client) ListNotifications(opt ListNotificationOptions) ([]*Notification // ReadNotifications mark notification threads as read func (c *Client) ReadNotifications(opt MarkNotificationOptions) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } if err := opt.Validate(c); err != nil { @@ -171,7 +177,7 @@ func (c *Client) ReadNotifications(opt MarkNotificationOptions) (*Response, erro // ListRepoNotifications list users's notification threads on a specific repo func (c *Client) ListRepoNotifications(owner, reponame string, opt ListNotificationOptions) ([]*NotificationThread, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } if err := opt.Validate(c); err != nil { @@ -186,7 +192,7 @@ func (c *Client) ListRepoNotifications(owner, reponame string, opt ListNotificat // ReadRepoNotifications mark notification threads as read on a specific repo func (c *Client) ReadRepoNotifications(owner, reponame string, opt MarkNotificationOptions) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } if err := opt.Validate(c); err != nil { diff --git a/vendor/code.gitea.io/sdk/gitea/oauth2.go b/vendor/code.gitea.io/sdk/gitea/oauth2.go index 80b1547..bbdfdaf 100644 --- a/vendor/code.gitea.io/sdk/gitea/oauth2.go +++ b/vendor/code.gitea.io/sdk/gitea/oauth2.go @@ -34,7 +34,7 @@ type CreateOauth2Option struct { // CreateOauth2 create an Oauth2 Application and returns a completed Oauth2 object. func (c *Client) CreateOauth2(opt CreateOauth2Option) (*Oauth2, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } body, err := json.Marshal(&opt) @@ -48,7 +48,7 @@ func (c *Client) CreateOauth2(opt CreateOauth2Option) (*Oauth2, *Response, error // UpdateOauth2 a specific Oauth2 Application by ID and return a completed Oauth2 object. func (c *Client) UpdateOauth2(oauth2id int64, opt CreateOauth2Option) (*Oauth2, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } body, err := json.Marshal(&opt) @@ -62,7 +62,7 @@ func (c *Client) UpdateOauth2(oauth2id int64, opt CreateOauth2Option) (*Oauth2, // GetOauth2 a specific Oauth2 Application by ID. func (c *Client) GetOauth2(oauth2id int64) (*Oauth2, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } oauth2s := &Oauth2{} @@ -72,7 +72,7 @@ func (c *Client) GetOauth2(oauth2id int64) (*Oauth2, *Response, error) { // ListOauth2 all of your Oauth2 Applications. func (c *Client) ListOauth2(opt ListOauth2Option) ([]*Oauth2, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } opt.setDefaults() @@ -83,7 +83,7 @@ func (c *Client) ListOauth2(opt ListOauth2Option) ([]*Oauth2, *Response, error) // DeleteOauth2 delete an Oauth2 application by ID func (c *Client) DeleteOauth2(oauth2id int64) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/user/applications/oauth2/%d", oauth2id), nil, nil) diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go index 24d70e2..c41ab3b 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/vendor/code.gitea.io/sdk/gitea/pull.go @@ -160,7 +160,7 @@ func (opt EditPullRequestOption) Validate(c *Client) error { return fmt.Errorf("title is empty") } if len(opt.Base) != 0 { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return fmt.Errorf("can not change base gitea to old") } } @@ -229,7 +229,7 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, *Re // getPullRequestDiffOrPatch gets the patch or diff file as bytes for a PR func (c *Client) getPullRequestDiffOrPatch(owner, repo, kind string, index int64) ([]byte, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { r, _, err2 := c.GetRepo(owner, repo) if err2 != nil { return nil, nil, err diff --git a/vendor/code.gitea.io/sdk/gitea/pull_review.go b/vendor/code.gitea.io/sdk/gitea/pull_review.go index e44dc7d..fc0c22c 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull_review.go +++ b/vendor/code.gitea.io/sdk/gitea/pull_review.go @@ -132,7 +132,7 @@ func (opt CreatePullReviewComment) Validate() error { // ListPullReviews lists all reviews of a pull request func (c *Client) ListPullReviews(owner, repo string, index int64, opt ListPullReviewsOptions) ([]*PullReview, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } opt.setDefaults() @@ -147,7 +147,7 @@ func (c *Client) ListPullReviews(owner, repo string, index int64, opt ListPullRe // GetPullReview gets a specific review of a pull request func (c *Client) GetPullReview(owner, repo string, index, id int64) (*PullReview, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } @@ -158,7 +158,7 @@ func (c *Client) GetPullReview(owner, repo string, index, id int64) (*PullReview // ListPullReviewComments lists all comments of a pull request review func (c *Client) ListPullReviewComments(owner, repo string, index, id int64) ([]*PullReviewComment, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } rcl := make([]*PullReviewComment, 0, 4) @@ -170,7 +170,7 @@ func (c *Client) ListPullReviewComments(owner, repo string, index, id int64) ([] // DeletePullReview delete a specific review from a pull request func (c *Client) DeletePullReview(owner, repo string, index, id int64) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } @@ -180,7 +180,7 @@ func (c *Client) DeletePullReview(owner, repo string, index, id int64) (*Respons // CreatePullReview create a review to an pull request func (c *Client) CreatePullReview(owner, repo string, index int64, opt CreatePullReviewOptions) (*PullReview, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } if err := opt.Validate(); err != nil { @@ -200,7 +200,7 @@ func (c *Client) CreatePullReview(owner, repo string, index int64, opt CreatePul // SubmitPullReview submit a pending review to an pull request func (c *Client) SubmitPullReview(owner, repo string, index, id int64, opt SubmitPullReviewOptions) (*PullReview, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } if err := opt.Validate(); err != nil { diff --git a/vendor/code.gitea.io/sdk/gitea/release.go b/vendor/code.gitea.io/sdk/gitea/release.go index 3440f1c..d8d28c5 100644 --- a/vendor/code.gitea.io/sdk/gitea/release.go +++ b/vendor/code.gitea.io/sdk/gitea/release.go @@ -57,7 +57,7 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, *Response, e // GetReleaseByTag get a release of a repository by tag func (c *Client) GetReleaseByTag(user, repo string, tag string) (*Release, *Response, error) { - if c.CheckServerVersionConstraint(">=1.13.0") != nil { + if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil { return c.fallbackGetReleaseByTag(user, repo, tag) } r := new(Release) diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go index c432724..a09f5a6 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/vendor/code.gitea.io/sdk/gitea/repo.go @@ -73,6 +73,20 @@ const ( RepoTypeMirror RepoType = "mirror" ) +// TrustModel represent how git signatures are handled in a repository +type TrustModel string + +const ( + // TrustModelDefault use TM set by global config + TrustModelDefault TrustModel = "default" + // TrustModelCollaborator gpg signature has to be owned by a repo collaborator + TrustModelCollaborator TrustModel = "collaborator" + // TrustModelCommitter gpg signature has to match committer + TrustModelCommitter TrustModel = "committer" + // TrustModelCollaboratorCommitter gpg signature has to match committer and owned by a repo collaborator + TrustModelCollaboratorCommitter TrustModel = "collaboratorcommitter" +) + // ListReposOptions options for listing repositories type ListReposOptions struct { ListOptions @@ -224,7 +238,7 @@ func (c *Client) SearchRepos(opt SearchRepoOptions) ([]*Repository, *Response, e } else { link.RawQuery = opt.QueryEncode() // IsPrivate only works on gitea >= 1.12.0 - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil && opt.IsPrivate != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil && opt.IsPrivate != nil { if *opt.IsPrivate { // private repos only not supported on gitea <= 1.11.x return nil, nil, err @@ -249,6 +263,8 @@ type CreateRepoOption struct { IssueLabels string `json:"issue_labels"` // Whether the repository should be auto-intialized? AutoInit bool `json:"auto_init"` + // Whether the repository is template + Template bool `json:"template"` // Gitignores to use Gitignores string `json:"gitignores"` // License to use @@ -257,19 +273,35 @@ type CreateRepoOption struct { Readme string `json:"readme"` // DefaultBranch of the repository (used when initializes and in template) DefaultBranch string `json:"default_branch"` + // TrustModel of the repository + TrustModel TrustModel `json:"trust_model"` } // Validate the CreateRepoOption struct -func (opt CreateRepoOption) Validate() error { +func (opt CreateRepoOption) Validate(c *Client) error { if len(strings.TrimSpace(opt.Name)) == 0 { return fmt.Errorf("name is empty") } + if len(opt.Name) > 100 { + return fmt.Errorf("name has more than 100 chars") + } + if len(opt.Description) > 255 { + return fmt.Errorf("name has more than 255 chars") + } + if len(opt.DefaultBranch) > 100 { + return fmt.Errorf("name has more than 100 chars") + } + if len(opt.TrustModel) != 0 { + if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + return err + } + } return nil } // CreateRepo creates a repository for authenticated user. func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, *Response, error) { - if err := opt.Validate(); err != nil { + if err := opt.Validate(c); err != nil { return nil, nil, err } body, err := json.Marshal(&opt) @@ -283,7 +315,7 @@ func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, *Response, error // CreateOrgRepo creates an organization repository for authenticated user. func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, *Response, error) { - if err := opt.Validate(); err != nil { + if err := opt.Validate(c); err != nil { return nil, nil, err } body, err := json.Marshal(&opt) diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch.go b/vendor/code.gitea.io/sdk/gitea/repo_branch.go index 0d6249e..6b0eec2 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_branch.go @@ -84,7 +84,7 @@ func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, *Response, e // DeleteRepoBranch delete a branch in a repository func (c *Client) DeleteRepoBranch(user, repo, branch string) (bool, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return false, nil, err } status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil) @@ -118,7 +118,7 @@ func (opt CreateBranchOption) Validate() error { // CreateBranch creates a branch for a user's repository func (c *Client) CreateBranch(owner, repo string, opt CreateBranchOption) (*Branch, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } if err := opt.Validate(); err != nil { diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go b/vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go index f4d47de..1e52080 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_branch_protection.go @@ -92,7 +92,7 @@ type ListBranchProtectionsOptions struct { // ListBranchProtections list branch protections for a repo func (c *Client) ListBranchProtections(owner, repo string, opt ListBranchProtectionsOptions) ([]*BranchProtection, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } bps := make([]*BranchProtection, 0, opt.PageSize) @@ -104,7 +104,7 @@ func (c *Client) ListBranchProtections(owner, repo string, opt ListBranchProtect // GetBranchProtection gets a branch protection func (c *Client) GetBranchProtection(owner, repo, name string) (*BranchProtection, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } bp := new(BranchProtection) @@ -114,7 +114,7 @@ func (c *Client) GetBranchProtection(owner, repo, name string) (*BranchProtectio // CreateBranchProtection creates a branch protection for a repo func (c *Client) CreateBranchProtection(owner, repo string, opt CreateBranchProtectionOption) (*BranchProtection, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } bp := new(BranchProtection) @@ -128,7 +128,7 @@ func (c *Client) CreateBranchProtection(owner, repo string, opt CreateBranchProt // EditBranchProtection edits a branch protection for a repo func (c *Client) EditBranchProtection(owner, repo, name string, opt EditBranchProtectionOption) (*BranchProtection, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } bp := new(BranchProtection) @@ -142,7 +142,7 @@ func (c *Client) EditBranchProtection(owner, repo, name string, opt EditBranchPr // DeleteBranchProtection deletes a branch protection for a repo func (c *Client) DeleteBranchProtection(owner, repo, name string) (*Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, err } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/branch_protections/%s", owner, repo, name), jsonHeader, nil) diff --git a/vendor/code.gitea.io/sdk/gitea/repo_commit.go b/vendor/code.gitea.io/sdk/gitea/repo_commit.go index e17d003..4b90b9c 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_commit.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_commit.go @@ -19,8 +19,9 @@ type Identity struct { // CommitMeta contains meta information of a commit in terms of API. type CommitMeta struct { - URL string `json:"url"` - SHA string `json:"sha"` + URL string `json:"url"` + SHA string `json:"sha"` + Created time.Time `json:"created"` } // CommitUser contains information of a user in the context of a commit. diff --git a/vendor/code.gitea.io/sdk/gitea/repo_file.go b/vendor/code.gitea.io/sdk/gitea/repo_file.go index 94f216f..b104980 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_file.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_file.go @@ -182,7 +182,7 @@ func (c *Client) DeleteFile(owner, repo, filepath string, opt DeleteFileOptions) func (c *Client) setDefaultBranchForOldVersions(owner, repo, branch string) (string, error) { if len(branch) == 0 { // Gitea >= 1.12.0 Use DefaultBranch on "", mimic this for older versions - if c.CheckServerVersionConstraint(">=1.12.0") != nil { + if c.checkServerVersionGreaterThanOrEqual(version1_12_0) != nil { r, _, err := c.GetRepo(owner, repo) if err != nil { return "", err diff --git a/vendor/code.gitea.io/sdk/gitea/repo_migrate.go b/vendor/code.gitea.io/sdk/gitea/repo_migrate.go index 583d800..518c6ae 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_migrate.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_migrate.go @@ -20,10 +20,10 @@ const ( GitServiceGithub GitServiceType = "github" // GitServiceGitlab represents a gitlab service GitServiceGitlab GitServiceType = "gitlab" + // GitServiceGitea represents a gitea service + GitServiceGitea GitServiceType = "gitea" // Not supported jet - // // GitServiceGitea represents a gitea service - // GitServiceGitea GitServiceType = "gitea" // // GitServiceGogs represents a gogs service // GitServiceGogs GitServiceType = "gogs" ) @@ -51,7 +51,7 @@ type MigrateRepoOption struct { } // Validate the MigrateRepoOption struct -func (opt *MigrateRepoOption) Validate() error { +func (opt *MigrateRepoOption) Validate(c *Client) error { // check user options if len(opt.CloneAddr) == 0 { return fmt.Errorf("CloneAddr required") @@ -69,6 +69,15 @@ func (opt *MigrateRepoOption) Validate() error { if len(opt.AuthToken) == 0 { return fmt.Errorf("github require token authentication") } + case GitServiceGitlab, GitServiceGitea: + if len(opt.AuthToken) == 0 { + return fmt.Errorf("%s require token authentication", opt.Service) + } + // Gitlab is supported since 1.12.0 but api cant handle it until 1.13.0 + // https://github.com/go-gitea/gitea/pull/12672 + if c.checkServerVersionGreaterThanOrEqual(version1_13_0) != nil { + return fmt.Errorf("migrate from service %s need gitea >= 1.13.0", opt.Service) + } } return nil } @@ -78,11 +87,11 @@ func (opt *MigrateRepoOption) Validate() error { // To migrate a repository for a organization, the authenticated user must be a // owner of the specified organization. func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, *Response, error) { - if err := opt.Validate(); err != nil { + if err := opt.Validate(c); err != nil { return nil, nil, err } - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { if len(opt.AuthToken) != 0 { // gitea <= 1.12 dont understand AuthToken opt.AuthUsername = opt.AuthToken diff --git a/vendor/code.gitea.io/sdk/gitea/repo_transfer.go b/vendor/code.gitea.io/sdk/gitea/repo_transfer.go index aedb0e5..d8d661b 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_transfer.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_transfer.go @@ -20,7 +20,7 @@ type TransferRepoOption struct { // TransferRepo transfers the ownership of a repository func (c *Client) TransferRepo(owner, reponame string, opt TransferRepoOption) (*Repository, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != nil { return nil, nil, err } body, err := json.Marshal(&opt) diff --git a/vendor/code.gitea.io/sdk/gitea/settings.go b/vendor/code.gitea.io/sdk/gitea/settings.go index 9c39e4e..9fa0a7a 100644 --- a/vendor/code.gitea.io/sdk/gitea/settings.go +++ b/vendor/code.gitea.io/sdk/gitea/settings.go @@ -33,7 +33,7 @@ type GlobalAttachmentSettings struct { // GetGlobalUISettings get global ui settings witch are exposed by API func (c *Client) GetGlobalUISettings() (*GlobalUISettings, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } conf := new(GlobalUISettings) @@ -43,7 +43,7 @@ func (c *Client) GetGlobalUISettings() (*GlobalUISettings, *Response, error) { // GetGlobalRepoSettings get global repository settings witch are exposed by API func (c *Client) GetGlobalRepoSettings() (*GlobalRepoSettings, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } conf := new(GlobalRepoSettings) @@ -53,7 +53,7 @@ func (c *Client) GetGlobalRepoSettings() (*GlobalRepoSettings, *Response, error) // GetGlobalAPISettings get global api settings witch are exposed by it func (c *Client) GetGlobalAPISettings() (*GlobalAPISettings, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } conf := new(GlobalAPISettings) @@ -63,7 +63,7 @@ func (c *Client) GetGlobalAPISettings() (*GlobalAPISettings, *Response, error) { // GetGlobalAttachmentSettings get global repository settings witch are exposed by API func (c *Client) GetGlobalAttachmentSettings() (*GlobalAttachmentSettings, *Response, error) { - if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { + if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != nil { return nil, nil, err } conf := new(GlobalAttachmentSettings) diff --git a/vendor/code.gitea.io/sdk/gitea/version.go b/vendor/code.gitea.io/sdk/gitea/version.go index 57c64dc..747117c 100644 --- a/vendor/code.gitea.io/sdk/gitea/version.go +++ b/vendor/code.gitea.io/sdk/gitea/version.go @@ -42,6 +42,32 @@ func (c *Client) CheckServerVersionConstraint(constraint string) error { return nil } +// predefined versions only have to be parsed by library once +var ( + version1_10_0, _ = version.NewVersion("1.10.0") + version1_11_0, _ = version.NewVersion("1.11.0") + version1_12_0, _ = version.NewVersion("1.12.0") + version1_13_0, _ = version.NewVersion("1.13.0") +) + +// checkServerVersionGreaterThanOrEqual is internally used to speed up things and ignore issues with prerelease +func (c *Client) checkServerVersionGreaterThanOrEqual(v *version.Version) error { + c.versionLock.RLock() + if c.serverVersion == nil { + c.versionLock.RUnlock() + if err := c.loadClientServerVersion(); err != nil { + return err + } + } else { + c.versionLock.RUnlock() + } + + if !c.serverVersion.GreaterThanOrEqual(v) { + return fmt.Errorf("gitea server at %s is older than %s", c.url, v.Original()) + } + return nil +} + // loadClientServerVersion init the serverVersion variable func (c *Client) loadClientServerVersion() error { c.versionLock.Lock() diff --git a/vendor/modules.txt b/vendor/modules.txt index a2d3df5..55de6e9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # code.gitea.io/gitea-vet v0.2.1 code.gitea.io/gitea-vet code.gitea.io/gitea-vet/checks -# code.gitea.io/sdk/gitea v0.13.1 +# code.gitea.io/sdk/gitea v0.13.2-0.20201112213603-e323ee0bc434 code.gitea.io/sdk/gitea # github.com/AlecAivazis/survey/v2 v2.2.2 github.com/AlecAivazis/survey/v2