ignore PRs in runIssuesList() (fixes #108) #110

Closed
noerw wants to merge 2 commits from noerw:issue-108/nopulls into main
9 changed files with 29 additions and 9 deletions

View File

@ -98,6 +98,9 @@ func runIssuesList(ctx *cli.Context) error {
}
for _, issue := range issues {
if issue.PullRequest != nil {
continue
}
name := issue.Poster.FullName
if len(name) == 0 {
name = issue.Poster.UserName

2
go.mod
View File

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

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.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=

View File

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

View File

@ -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()
}

View File

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

View File

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

View File

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

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