bump code.gitea.io/sdk/gitea from untaged to 0.11.0 (#92)

bump code.gitea.io/sdk/gitea from untaged to 0.11.0

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/92
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
6543
2020-02-07 13:53:15 +00:00
committed by techknowlogick
parent 8d61d8beec
commit c8cbd6b0ee
23 changed files with 1459 additions and 54 deletions

View File

@ -9,6 +9,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"net/url"
"time"
)
@ -58,18 +59,36 @@ type PullRequest struct {
// ListPullRequestsOptions options for listing pull requests
type ListPullRequestsOptions struct {
Page int `json:"page"`
Page int `json:"page"`
// open, closed, all
State string `json:"state"`
// oldest, recentupdate, leastupdate, mostcomment, leastcomment, priority
Sort string `json:"sort"`
Milestone int64 `json:"milestone"`
}
// ListRepoPullRequests list PRs of one repository
func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) {
body, err := json.Marshal(&opt)
if err != nil {
return nil, err
}
// declare variables
link, _ := url.Parse(fmt.Sprintf("/repos/%s/%s/pulls", owner, repo))
prs := make([]*PullRequest, 0, 10)
return prs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), jsonHeader, bytes.NewReader(body), &prs)
query := make(url.Values)
// add options to query
if opt.Page > 0 {
query.Add("page", fmt.Sprintf("%d", opt.Page))
}
if len(opt.State) > 0 {
query.Add("state", opt.State)
}
if len(opt.Sort) > 0 {
query.Add("sort", opt.Sort)
}
if opt.Milestone > 0 {
query.Add("milestone", fmt.Sprintf("%d", opt.Milestone))
}
link.RawQuery = query.Encode()
// request
return prs, c.getParsedResponse("GET", link.String(), jsonHeader, nil, &prs)
}
// GetPullRequest get information of one PR