提交 3ab56f59 编写于 作者: M Mislav Marohnić

Fix assigning labels/assignees without the other

The GitHub API doesn't seem to like receiving `"assignees": null`.

Fixes #1240
上级 328df93f
......@@ -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 {
......
......@@ -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)
}
......
......@@ -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"] = %(<https://api.github.com/repositories/12345?per_page=100&page=2>; 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"
......
......@@ -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"
}
"""
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册