Skip to content

Commit

Permalink
Fixes #8293: rudder-dev doesn't handle PR creation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jooooooon committed May 16, 2016
1 parent 0f3f90f commit 0a4a8b3
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions scripts/rudder-dev/rudder-dev
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,19 @@ def create_pr(master_branch, info, message):
pr += ' "head": "' + user + ':' + current_branch + '",'
pr += ' "base": "' + master_branch + '" }'
result = github_request(url, "Creating PR ...", pr_url=None, post_data=pr)
return result['html_url']

if 'html_url' in result:
return result['html_url']
elif 'errors' in result and 'message' in result['errors'][0]:
error_message = result['errors'][0]['message']
logfail("Error occured in create PR: " + error_message)
else:
logfail("Unkown error occured in create PR")

if not force:
exit(16)
else:
return None


# add a message to a given pull-request on github
Expand Down Expand Up @@ -1418,10 +1430,10 @@ def commit(trigraph=None, message=None):

# create PR
pr_url = create_pr(master_branch, info, message)
print("PR URL: " + pr_url)
print("PR URL: " + str(pr_url))

# update ticket
if REDMINE_TOKEN is not None and pr_url is not None:
if REDMINE_TOKEN is not None:
if can_modify_issues(info['project_id']):
user = ask_username(info['project_id'], trigraph)
else:
Expand Down Expand Up @@ -1537,15 +1549,16 @@ def retarget(version=None):
# create new PR
pr_url = create_pr(ticket_branch, info, "Replacing previous PR: " + info['pr'])

# close old PR
close_pr(info['pr'], "PR replaced by " + pr_url)
if pr_url:
# close old PR
close_pr(info['pr'], "PR replaced by " + pr_url)

# update ticket
user = None
if 'last_assignee' in info:
user = info['last_assignee']
ticket_to_TR(info, user, pr_url)
print("New PR URL: " + pr_url)
# update ticket
user = None
if 'last_assignee' in info:
user = info['last_assignee']
ticket_to_TR(info, user, pr_url)
print("New PR URL: " + pr_url)


# ckeckout version, pull
Expand Down

0 comments on commit 0a4a8b3

Please sign in to comment.