From 08a00add6d47e5a49883d9bc1b8f633329a50600 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Wed, 1 Apr 2020 08:35:42 +0000 Subject: [PATCH] ignore PRs in runIssuesList() (#111) Merge branch 'master' into 108-issues Merge branch 'master' into 108-issues ignore pullrequests Update SDK v0.11.0 -> 0.11.2 Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/111 Reviewed-by: John Olheiser Reviewed-by: Lunny Xiao --- cmd/issues.go | 1 + go.mod | 2 +- go.sum | 4 ++-- vendor/code.gitea.io/sdk/gitea/client.go | 4 +++- vendor/code.gitea.io/sdk/gitea/issue.go | 14 ++++++++++++++ vendor/code.gitea.io/sdk/gitea/repo_topics.go | 4 ++-- vendor/code.gitea.io/sdk/gitea/user_app.go | 3 ++- vendor/code.gitea.io/sdk/gitea/user_email.go | 2 +- vendor/modules.txt | 2 +- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cmd/issues.go b/cmd/issues.go index 836a642..ea2dd17 100644 --- a/cmd/issues.go +++ b/cmd/issues.go @@ -92,6 +92,7 @@ func runIssuesList(ctx *cli.Context) error { issues, err := login.Client().ListRepoIssues(owner, repo, gitea.ListIssueOption{ Page: 0, State: string(state), + Type: gitea.IssueTypeIssue, }) if err != nil { diff --git a/go.mod b/go.mod index 3b336b8..5e19f80 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.gitea.io/tea go 1.12 require ( - code.gitea.io/sdk/gitea v0.11.0 + code.gitea.io/sdk/gitea v0.11.2 github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195 github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7 diff --git a/go.sum b/go.sum index 97d698a..af5b280 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -code.gitea.io/sdk/gitea v0.11.0 h1:XgZtmImZsjMC+Z1WBfO6bYTCOJiGp+7w0HKmfhTwytw= -code.gitea.io/sdk/gitea v0.11.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY= +code.gitea.io/sdk/gitea v0.11.2 h1:D0xIRlHv3IckzdYOWzHK1bPvlkXdA4LD909UYyBdi1o= +code.gitea.io/sdk/gitea v0.11.2/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= diff --git a/vendor/code.gitea.io/sdk/gitea/client.go b/vendor/code.gitea.io/sdk/gitea/client.go index f63fe03..b1619ef 100644 --- a/vendor/code.gitea.io/sdk/gitea/client.go +++ b/vendor/code.gitea.io/sdk/gitea/client.go @@ -22,7 +22,7 @@ var jsonHeader = http.Header{"content-type": []string{"application/json"}} // Version return the library version func Version() string { - return "0.12.3" + return "0.11.1" } // Client represents a Gitea API client. @@ -110,6 +110,8 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re return nil, errors.New("409 Conflict") case 422: return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) + case 500: + return nil, fmt.Errorf("500 Internal Server Error, request: '%s' with '%s' method and '%s' header", path, method, header) } if resp.StatusCode/100 != 2 { diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/vendor/code.gitea.io/sdk/gitea/issue.go index 73243ee..5078329 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/vendor/code.gitea.io/sdk/gitea/issue.go @@ -48,10 +48,23 @@ type ListIssueOption struct { Page int // open, closed, all State string + Type IssueType Labels []string KeyWord string } +// IssueType is issue a pull or only an issue +type IssueType string + +const ( + // IssueTypeAll pr and issue + IssueTypeAll IssueType = "" + // IssueTypeIssue only issues + IssueTypeIssue IssueType = "issues" + // IssueTypePull only pulls + IssueTypePull IssueType = "pulls" +) + // QueryEncode turns options into querystring argument func (opt *ListIssueOption) QueryEncode() string { query := make(url.Values) @@ -81,6 +94,7 @@ func (opt *ListIssueOption) QueryEncode() string { if len(opt.KeyWord) > 0 { query.Add("q", opt.KeyWord) } + query.Add("type", string(opt.Type)) return query.Encode() } diff --git a/vendor/code.gitea.io/sdk/gitea/repo_topics.go b/vendor/code.gitea.io/sdk/gitea/repo_topics.go index 5850568..b96259b 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_topics.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_topics.go @@ -22,13 +22,13 @@ func (c *Client) ListRepoTopics(user, repo string) (*TopicsList, error) { } // SetRepoTopics replaces the list of repo's topics -func (c *Client) SetRepoTopics(user, repo, list TopicsList) error { +func (c *Client) SetRepoTopics(user, repo string, list TopicsList) error { body, err := json.Marshal(&list) if err != nil { return err } - _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/topics", user, repo), nil, bytes.NewReader(body)) + _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/topics", user, repo), jsonHeader, bytes.NewReader(body)) return err } diff --git a/vendor/code.gitea.io/sdk/gitea/user_app.go b/vendor/code.gitea.io/sdk/gitea/user_app.go index 773dcf3..b253c98 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_app.go +++ b/vendor/code.gitea.io/sdk/gitea/user_app.go @@ -54,6 +54,7 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio // DeleteAccessToken delete token with key id func (c *Client) DeleteAccessToken(user string, keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil) + _, err := c.getResponse("DELETE", fmt.Sprintf("/users/%s/tokens/%d", user, keyID), + http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, c.password)}}, nil) return err } diff --git a/vendor/code.gitea.io/sdk/gitea/user_email.go b/vendor/code.gitea.io/sdk/gitea/user_email.go index 7823db1..fffafe1 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_email.go +++ b/vendor/code.gitea.io/sdk/gitea/user_email.go @@ -35,7 +35,7 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) { return nil, err } emails := make([]*Email, 0, 3) - return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails) + return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), &emails) } // DeleteEmailOption options when deleting email addresses diff --git a/vendor/modules.txt b/vendor/modules.txt index ee0d191..bfc8880 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# code.gitea.io/sdk/gitea v0.11.0 +# code.gitea.io/sdk/gitea v0.11.2 code.gitea.io/sdk/gitea # github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195 github.com/araddon/dateparse