diff --git a/commands/issue.go b/commands/issue.go index 7cc8f15788ddd55c521ab743af24a23617b53da4..8e990f55bdfe8f0cb3c445d97d621a85871774ae 100644 --- a/commands/issue.go +++ b/commands/issue.go @@ -366,10 +366,16 @@ func createIssue(cmd *Command, args *Args) { } params := map[string]interface{}{ - "title": title, - "body": body, - "labels": flagIssueLabels, - "assignees": flagIssueAssignees, + "title": title, + "body": body, + } + + if len(flagIssueLabels) > 0 { + params["labels"] = flagIssueLabels + } + + if len(flagIssueAssignees) > 0 { + params["assignees"] = flagIssueAssignees } if flagIssueMilestone > 0 { diff --git a/commands/pull_request.go b/commands/pull_request.go index cb389a3f66244d2dd6f0976d73f3d873b100aa3f..aa44f99a2075d3f5140456d709d959379950ad0a 100644 --- a/commands/pull_request.go +++ b/commands/pull_request.go @@ -245,17 +245,18 @@ func pullRequest(cmd *Command, args *Args) { pullRequestURL = pr.HtmlUrl - if len(flagPullRequestAssignees) > 0 || flagPullRequestMilestone > 0 || - len(flagPullRequestLabels) > 0 { - - params := map[string]interface{}{ - "labels": flagPullRequestLabels, - "assignees": flagPullRequestAssignees, - } - if flagPullRequestMilestone > 0 { - params["milestone"] = flagPullRequestMilestone - } + params = map[string]interface{}{} + if len(flagPullRequestLabels) > 0 { + params["labels"] = flagPullRequestLabels + } + if len(flagPullRequestAssignees) > 0 { + params["assignees"] = flagPullRequestAssignees + } + if flagPullRequestMilestone > 0 { + params["milestone"] = flagPullRequestMilestone + } + if len(params) > 0 { err = client.UpdateIssue(baseProject, pr.Number, params) utils.Check(err) } diff --git a/features/issue.feature b/features/issue.feature index 218fcaa0e27b932849ed3ee46fdfb27659f67f88..c2c6b86ffc89c820e6fab693fbded3a9eba5fec3 100644 --- a/features/issue.feature +++ b/features/issue.feature @@ -84,7 +84,7 @@ Feature: hub issue Given the GitHub API server: """ get('/repos/github/hub/issues') { - assert :per_page => "100", :page => nil + assert :per_page => "100", :page => :no response.headers["Link"] = %(; rel="next") json [ { :number => 102, @@ -197,7 +197,7 @@ Feature: hub issue post('/repos/github/hub/issues') { assert :title => "Not workie, pls fix", :body => "", - :labels => nil + :labels => :no status 201 json :html_url => "https://github.com/github/hub/issues/1337" @@ -227,8 +227,8 @@ Feature: hub issue post('/repos/github/hub/issues') { assert :title => "hello", :body => "", - :milestone => nil, - :assignees => nil, + :milestone => :no, + :assignees => :no, :labels => ["wont fix", "docs", "nope"] status 201 @@ -249,7 +249,7 @@ Feature: hub issue :body => "", :milestone => 12, :assignees => ["mislav", "josh", "pcorpet"], - :labels => nil + :labels => :no status 201 json :html_url => "https://github.com/github/hub/issues/1337" diff --git a/features/pull_request.feature b/features/pull_request.feature index 55c078d540548aa4984a0f89cce283abc354b992..f97cbde2f1d31381be579907859a9a5532de61d6 100644 --- a/features/pull_request.feature +++ b/features/pull_request.feature @@ -695,7 +695,7 @@ BODY json :html_url => "the://url", :number => 1234 } patch('/repos/mislav/coral/issues/1234') { - assert :assignees => ["mislav", "josh", "pcorpet"], :labels => nil + assert :assignees => ["mislav", "josh", "pcorpet"], :labels => :no json :html_url => "the://url" } """ @@ -729,7 +729,7 @@ BODY json :html_url => "the://url", :number => 1234 } patch('/repos/mislav/coral/issues/1234') { - assert :labels => ["feature", "release", "docs"] + assert :labels => ["feature", "release", "docs"], :assignees => :no json :html_url => "the://url" } """ diff --git a/features/support/local_server.rb b/features/support/local_server.rb index 7c3b67fa95c2618ad88754facb453d47df188993..2b8ca9bf9e5ab788dedad27f74e8272563e0d820 100644 --- a/features/support/local_server.rb +++ b/features/support/local_server.rb @@ -69,7 +69,14 @@ module Hub def assert(expected) expected.each do |key, value| - if params[key] != value + if :no == value + halt 422, json( + :message => "expected %s not to be passed; got %s" % [ + key.inspect, + params[key].inspect + ] + ) if params.key?(key.to_s) + elsif params[key] != value halt 422, json( :message => "expected %s to be %s; got %s" % [ key.inspect,