diff --git a/README.md b/README.md index 4c6bc38..1d480cd 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ import "code.gitea.io/sdk/gitea" ## Version Requirements * go >= 1.13 - * gitea >= 1.10 + * gitea >= 1.11 ## Contributing diff --git a/gitea/client.go b/gitea/client.go index 7516ff6..b353e6e 100644 --- a/gitea/client.go +++ b/gitea/client.go @@ -23,7 +23,7 @@ var jsonHeader = http.Header{"content-type": []string{"application/json"}} // Version return the library version func Version() string { - return "0.13.0" + return "0.14.0" } // Client represents a Gitea API client. @@ -55,7 +55,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.CheckServerVersionConstraint(">=1.11.0"); err != nil { return nil, err } return client, nil diff --git a/gitea/issue_reaction.go b/gitea/issue_reaction.go index a70209a..efdac08 100644 --- a/gitea/issue_reaction.go +++ b/gitea/issue_reaction.go @@ -20,9 +20,6 @@ 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 { - return nil, nil, err - } reactions := make([]*Reaction, 0, 10) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/reactions", owner, repo, index), nil, nil, &reactions) return reactions, resp, err @@ -30,9 +27,6 @@ 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 { - return nil, nil, err - } reactions := make([]*Reaction, 0, 10) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments/%d/reactions", owner, repo, commentID), nil, nil, &reactions) return reactions, resp, err @@ -45,9 +39,6 @@ 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 { - return nil, nil, err - } reactionResponse := new(Reaction) body, err := json.Marshal(&editReactionOption{Reaction: reaction}) if err != nil { @@ -61,9 +52,6 @@ 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 { - return nil, err - } body, err := json.Marshal(&editReactionOption{Reaction: reaction}) if err != nil { return nil, err @@ -74,9 +62,6 @@ 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 { - return nil, nil, err - } reactionResponse := new(Reaction) body, err := json.Marshal(&editReactionOption{Reaction: reaction}) if err != nil { @@ -90,9 +75,6 @@ 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 { - return nil, err - } body, err := json.Marshal(&editReactionOption{Reaction: reaction}) if err != nil { return nil, err diff --git a/gitea/issue_subscription.go b/gitea/issue_subscription.go index 52e67ed..4770389 100644 --- a/gitea/issue_subscription.go +++ b/gitea/issue_subscription.go @@ -11,9 +11,6 @@ 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 { - return nil, nil, err - } subscribers := make([]*User, 0, 10) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions", owner, repo, index), nil, nil, &subscribers) return subscribers, resp, err @@ -21,9 +18,6 @@ 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 { - return nil, err - } status, resp, err := c.getStatusCode("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) if err != nil { return resp, err @@ -39,9 +33,6 @@ 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 { - return nil, err - } status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/subscriptions/%s", owner, repo, index, user), nil, nil) if err != nil { return resp, err diff --git a/gitea/issue_tracked_time.go b/gitea/issue_tracked_time.go index 481c831..5971922 100644 --- a/gitea/issue_tracked_time.go +++ b/gitea/issue_tracked_time.go @@ -27,9 +27,6 @@ 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 { - return nil, nil, err - } times := make([]*TrackedTime, 0, 10) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×) return times, resp, err @@ -37,9 +34,6 @@ 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 { - return nil, nil, err - } times := make([]*TrackedTime, 0, 10) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×) return times, resp, err @@ -47,9 +41,6 @@ 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 { - return nil, nil, err - } times := make([]*TrackedTime, 0, 10) resp, err := c.getParsedResponse("GET", "/user/times", nil, nil, ×) return times, resp, err @@ -75,9 +66,6 @@ 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 { - return nil, nil, err - } if err := opt.Validate(); err != nil { return nil, nil, err } @@ -99,9 +87,6 @@ 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 { - return nil, nil, err - } opt.setDefaults() times := make([]*TrackedTime, 0, opt.PageSize) resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times?%s", owner, repo, index, opt.getURLQuery().Encode()), nil, nil, ×) @@ -110,18 +95,12 @@ 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 { - return nil, err - } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil) return resp, 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 { - return nil, err - } _, resp, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/times/%d", owner, repo, index, timeID), nil, nil) return resp, err }