From 7418cfb971dba11675cb87f2e3df6c45f0bae57a Mon Sep 17 00:00:00 2001 From: Ryan Lower Date: Thu, 26 Mar 2015 20:50:23 -0700 Subject: [PATCH] Add Sort and Direction to PullRequestListOptions As per https://developer.github.com/v3/pulls/#list-pull-requests --- github/pulls.go | 9 +++++++++ github/pulls_test.go | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/github/pulls.go b/github/pulls.go index cf07110..71cf2e2 100644 --- a/github/pulls.go +++ b/github/pulls.go @@ -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 } diff --git a/github/pulls_test.go b/github/pulls_test.go index a1c1765..6ac0ddb 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -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 {