Start v0.14.0 Development (#421)

remove unessesary version checks

Gitea Version Requirement >= 1.11

set lib version string

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/421
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
This commit is contained in:
6543 2020-09-15 20:46:08 +00:00
parent e758ffeaa0
commit 3d7419dabb
5 changed files with 3 additions and 51 deletions

View file

@ -12,7 +12,7 @@ import "code.gitea.io/sdk/gitea"
## Version Requirements
* go >= 1.13
* gitea >= 1.10
* gitea >= 1.11
## Contributing

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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, &times)
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, &times)
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, &times)
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, &times)
@ -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
}