diff --git a/commands/pr.go b/commands/pr.go index e876c2e1259799046e78b2c670b96e39dead0ee5..443cd59bc732e37d6242ca1ace34677b1547732e 100644 --- a/commands/pr.go +++ b/commands/pr.go @@ -56,6 +56,10 @@ pr checkout [] %b: body + %B: base branch + + %H: head branch + %au: login name of author %as: comma-separated list of assignees diff --git a/features/pr-list.feature b/features/pr-list.feature new file mode 100644 index 0000000000000000000000000000000000000000..074aa983989a0c4fe38a7e5f874e1884f4581878 --- /dev/null +++ b/features/pr-list.feature @@ -0,0 +1,90 @@ +Feature: hub pr list + Background: + Given I am in "git://github.com/github/hub.git" git repo + And I am "defunkt" on github.com with OAuth token "OTOKEN" + + Scenario: List pulls + Given the GitHub API server: + """ + get('/repos/github/hub/pulls') { + assert :per_page => "100", + :page => :no, + :sort => nil, + :direction => nil + + response.headers["Link"] = %(; rel="next") + + json [ + { :number => 999, + :title => "First", + :state => "open", + :base => { :ref => "master", :label => "github:master" }, + :head => { :ref => "patch-1", :label => "octocat:patch-1" }, + :user => { :login => "octocat" }, + }, + { :number => 102, + :title => "Second", + :state => "open", + :base => { :ref => "master", :label => "github:master" }, + :head => { :ref => "patch-2", :label => "octocat:patch-2" }, + :user => { :login => "octocat" }, + }, + { :number => 13, + :title => "Third", + :state => "open", + :base => { :ref => "master", :label => "github:master" }, + :head => { :ref => "patch-3", :label => "octocat:patch-3" }, + :user => { :login => "octocat" }, + }, + ] + } + + get('/repositories/12345') { + assert :per_page => "100", + :page => "2" + + json [ + { :number => 7, + :title => "Fourth", + :state => "open", + :base => { :ref => "master", :label => "github:master" }, + :head => { :ref => "patch-4", :label => "octocat:patch-4" }, + :user => { :login => "octocat" }, + }, + ] + } + """ + When I successfully run `hub pr list` + Then the output should contain exactly: + """ + #999 First + #102 Second + #13 Third + #7 Fourth\n + """ + + Scenario: Sort by number of comments ascending + Given the GitHub API server: + """ + get('/repos/github/hub/pulls') { + assert :sort => "comments", + :direction => "asc" + + json [] + } + """ + When I successfully run `hub pr list -o comments -^` + Then the output should contain exactly "" + + Scenario: Filter by base and head + Given the GitHub API server: + """ + get('/repos/github/hub/pulls') { + assert :base => "develop", + :head => "patch-1" + + json [] + } + """ + When I successfully run `hub pr list -b develop -h patch-1` + Then the output should contain exactly ""