Browse Source

Add Sort and Direction to PullRequestListOptions

As per https://developer.github.com/v3/pulls/#list-pull-requests
Ryan Lower 11 years ago
committed by Will Norris
parent
commit
7418cfb971
2 changed files with 16 additions and 5 deletions
  1. +9
    -0
      github/pulls.go
  2. +7
    -5
      github/pulls_test.go

+ 9
- 0
github/pulls.go View File

@ -75,6 +75,15 @@ type PullRequestListOptions struct {
// Base filters pull requests by base branch name.
Base string `url:"base,omitempty"`
// Sort specifies how to sort pull requests. Possible values are: created,
// updated, popularity, long-running. Default is "created".
Sort string `url:"sort,omitempty"`
// Direction in which to sort pull requests. Possible values are: asc, desc.
// If Sort is "created" or not specified, Default is "desc", otherwise Default
// is "asc"
Direction string `url:"direction,omitempty"`
ListOptions
}


+ 7
- 5
github/pulls_test.go View File

@ -20,15 +20,17 @@ func TestPullRequestsService_List(t *testing.T) {
mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"state": "closed",
"head": "h",
"base": "b",
"page": "2",
"state": "closed",
"head": "h",
"base": "b",
"sort": "created",
"direction": "desc",
"page": "2",
})
fmt.Fprint(w, `[{"number":1}]`)
})
opt := &PullRequestListOptions{"closed", "h", "b", ListOptions{Page: 2}}
opt := &PullRequestListOptions{"closed", "h", "b", "created", "desc", ListOptions{Page: 2}}
pulls, _, err := client.PullRequests.List("o", "r", opt)
if err != nil {


Loading…
Cancel
Save