[Backport] Add IssueType as filter for ListIssues (#288)

wait for CI to get job done

add IssueType as filter for ListIssues

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/288
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
6543 2020-03-29 18:19:09 +00:00 committed by Andrew Thornton
parent 89970fb7b5
commit e688af22be
2 changed files with 15 additions and 0 deletions

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

@ -18,6 +18,7 @@ func TestIssue(t *testing.T) {
c := newTestClient()
createIssue(t, c)
time.Sleep(time.Second)
listIssues(t, c)
}