Skip to content

Commit e6299bd

Browse files
authored
Merge pull request #313 from llucax/fix-pull-new
Fix pull new broken by #306
2 parents 01c0ef7 + 1da9c54 commit e6299bd

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

git-hub

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,19 +1287,14 @@ class IssueCmd (CmdGroup):
12871287
"number ID to the %s" % cls.name)
12881288
@classmethod
12891289
def run(cls, parser, args):
1290-
# URL fixed to issues, pull requests updates are made
1291-
# through issues to allow changing labels, assignee and
1292-
# milestone (even when GitHub itself doesn't support it
1293-
# :D)
1294-
url = '/repos/%s/issues/%s' % (config.upstream, args.issue)
12951290
title_body = dict()
12961291
msg = args.message
12971292
title = args.title
12981293
if title:
12991294
title_body['title'] = title
13001295
if args.edit_message:
13011296
if not msg:
1302-
issue = req.get(url)
1297+
issue = req.get(cls.url(args.issue))
13031298
msg = title if title else issue['title']
13041299
if issue['body']:
13051300
msg += '\n\n' + issue['body']
@@ -1308,11 +1303,14 @@ class IssueCmd (CmdGroup):
13081303
(title, body) = split_titled_message(msg)
13091304
title_body['title'] = title
13101305
title_body['body'] = body
1311-
issue = cls._do_update(url, args.labels, args.assignee,
1312-
args.milestone, args.state, **title_body)
1313-
cls.print_issue_summary(issue)
1306+
issue = cls._do_update(args.issue, args.labels,
1307+
args.assignee, args.milestone, args.state, **title_body)
1308+
if issue is None:
1309+
infof('Nothing to update for #{}', args.issue)
1310+
else:
1311+
cls.print_issue_summary(issue)
13141312
@classmethod
1315-
def _do_update(cls, url, labels=None, assignee=None,
1313+
def _do_update(cls, issue_num, labels=None, assignee=None,
13161314
milestone=None, state=None, title=None, body=None):
13171315
params = dict()
13181316
# Should labels be cleared?
@@ -1330,7 +1328,12 @@ class IssueCmd (CmdGroup):
13301328
params['title'] = title
13311329
if body:
13321330
params['body'] = body
1333-
return req.patch(url, **params)
1331+
if not params:
1332+
return None # Make sure we don't make an invalid empty request
1333+
# The URL is "hardcoded" to the issue URL here because the GitHub
1334+
# API allows updating some metadata (like assignee, milestone and
1335+
# labels), through it.
1336+
return req.patch(IssueUtil.url(issue_num), **params)
13341337

13351338
class CommentCmd (IssueUtil):
13361339
cmd_help = "add a comment to an existing issue"

0 commit comments

Comments
 (0)