diff --git a/commands/issue.go b/commands/issue.go index e3f9faeb..6e662b83 100644 --- a/commands/issue.go +++ b/commands/issue.go @@ -33,6 +33,7 @@ var ( `, } + flagIssueAssignee, flagIssueMessage, flagIssueFile string @@ -44,6 +45,8 @@ func init() { cmdCreateIssue.Flag.StringVarP(&flagIssueFile, "file", "f", "", "FILE") cmdCreateIssue.Flag.VarP(&flagIssueLabels, "label", "l", "LABEL") + cmdIssue.Flag.StringVarP(&flagIssueAssignee, "assignee", "a", "", "ASSIGNEE") + cmdIssue.Use(cmdCreateIssue) CmdRunner.Use(cmdIssue) } @@ -66,8 +69,11 @@ func issue(cmd *Command, args *Args) { } else { url = issue.HTMLURL } - // "nobody" should have more than 1 million github issues - ui.Printf("% 7d] %s ( %s )\n", issue.Number, issue.Title, url) + + if flagIssueAssignee == "" || issue.Assignee.Login == flagIssueAssignee { + // "nobody" should have more than 1 million github issues + ui.Printf("% 7d] %s ( %s )\n", issue.Number, issue.Title, url) + } } } }) diff --git a/features/issue.feature b/features/issue.feature new file mode 100644 index 00000000..e76a8a2e --- /dev/null +++ b/features/issue.feature @@ -0,0 +1,31 @@ +Feature: hub issue + Background: + Given I am in "git://github.com/github/hub.git" git repo + And I am "cornwe19" on github.com with OAuth token "OTOKEN" + + Scenario: Fetch issues + Given the remote issues of "github/hub" are: + """ + [ + { :number => 102, + :title => "First issue", + :html_url => "https://github.com/github/hub/issues/102", + :assignee => { + :login => "octokit" + } + }, + { :number => 103, + :title => "Second issue", + :html_url => "https://github.com/github/hub/issues/103", + :assignee => { + :login => "cornwe19" + } + } + ] + """ + When I run `hub issue -a cornwe19` + Then the output should contain exactly: + """ + 103] Second issue ( https://github.com/github/hub/issues/103 )\n + """ + And the exit status should be 0 diff --git a/features/steps.rb b/features/steps.rb index a096ecbd..2ca1fe1d 100644 --- a/features/steps.rb +++ b/features/steps.rb @@ -82,6 +82,15 @@ Given(/^there is a commit named "([^"]+)"$/) do |name| run_silent %(git reset --quiet --hard HEAD^) end +Given(/^the remote issues of "(.*?)" are:$/) do |proj, json_value| + status_endpoint = <<-EOS + get('/repos/#{proj}/issues') { + json(#{json_value}) + } + EOS + step %{the GitHub API server:}, status_endpoint +end + When(/^I make (a|\d+) commits?(?: with message "([^"]+)")?$/) do |num, msg| num = num == 'a' ? 1 : num.to_i num.times { empty_commit(msg) }