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 <john.olheiser@gmail.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
6543 2020-04-01 08:35:42 +00:00 committed by Lunny Xiao
parent 7a10ea10df
commit 08a00add6d
9 changed files with 27 additions and 9 deletions

View File

@ -92,6 +92,7 @@ func runIssuesList(ctx *cli.Context) error {
issues, err := login.Client().ListRepoIssues(owner, repo, gitea.ListIssueOption{ issues, err := login.Client().ListRepoIssues(owner, repo, gitea.ListIssueOption{
Page: 0, Page: 0,
State: string(state), State: string(state),
Type: gitea.IssueTypeIssue,
}) })
if err != nil { if err != nil {

2
go.mod
View File

@ -3,7 +3,7 @@ module code.gitea.io/tea
go 1.12 go 1.12
require ( 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/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7 github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7

4
go.sum
View File

@ -1,5 +1,5 @@
code.gitea.io/sdk/gitea v0.11.0 h1:XgZtmImZsjMC+Z1WBfO6bYTCOJiGp+7w0HKmfhTwytw= code.gitea.io/sdk/gitea v0.11.2 h1:D0xIRlHv3IckzdYOWzHK1bPvlkXdA4LD909UYyBdi1o=
code.gitea.io/sdk/gitea v0.11.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY= 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/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 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=

View File

@ -22,7 +22,7 @@ var jsonHeader = http.Header{"content-type": []string{"application/json"}}
// Version return the library version // Version return the library version
func Version() string { func Version() string {
return "0.12.3" return "0.11.1"
} }
// Client represents a Gitea API client. // 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") return nil, errors.New("409 Conflict")
case 422: case 422:
return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) 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 { if resp.StatusCode/100 != 2 {

View File

@ -48,10 +48,23 @@ type ListIssueOption struct {
Page int Page int
// open, closed, all // open, closed, all
State string State string
Type IssueType
Labels []string Labels []string
KeyWord 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 // QueryEncode turns options into querystring argument
func (opt *ListIssueOption) QueryEncode() string { func (opt *ListIssueOption) QueryEncode() string {
query := make(url.Values) query := make(url.Values)
@ -81,6 +94,7 @@ func (opt *ListIssueOption) QueryEncode() string {
if len(opt.KeyWord) > 0 { if len(opt.KeyWord) > 0 {
query.Add("q", opt.KeyWord) query.Add("q", opt.KeyWord)
} }
query.Add("type", string(opt.Type))
return query.Encode() return query.Encode()
} }

View File

@ -22,13 +22,13 @@ func (c *Client) ListRepoTopics(user, repo string) (*TopicsList, error) {
} }
// SetRepoTopics replaces the list of repo's topics // 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) body, err := json.Marshal(&list)
if err != nil { if err != nil {
return err 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 return err
} }

View File

@ -54,6 +54,7 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio
// DeleteAccessToken delete token with key id // DeleteAccessToken delete token with key id
func (c *Client) DeleteAccessToken(user string, keyID int64) error { 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 return err
} }

View File

@ -35,7 +35,7 @@ func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) {
return nil, err return nil, err
} }
emails := make([]*Email, 0, 3) 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 // DeleteEmailOption options when deleting email addresses

2
vendor/modules.txt vendored
View File

@ -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 code.gitea.io/sdk/gitea
# github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195 # github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195
github.com/araddon/dateparse github.com/araddon/dateparse