Skip to content

Commit

Permalink
[SPARK-23044] Error handling for jira assignment
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?

* If there is any error while trying to assign the jira, prompt again
* Filter out the "Apache Spark" choice
* allow arbitrary user ids to be entered

## How was this patch tested?

Couldn't really test the error case, just some testing of similar-ish code in python shell.  Haven't run a merge yet.

Author: Imran Rashid <irashid@cloudera.com>

Closes #20236 from squito/SPARK-23044.
  • Loading branch information
squito authored and Marcelo Vanzin committed Jan 17, 2018
1 parent 4371466 commit 5ae3333
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions dev/merge_spark_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import re
import subprocess
import sys
import traceback
import urllib2

try:
Expand Down Expand Up @@ -298,24 +299,37 @@ def choose_jira_assignee(issue, asf_jira):
Prompt the user to choose who to assign the issue to in jira, given a list of candidates,
including the original reporter and all commentors
"""
reporter = issue.fields.reporter
commentors = map(lambda x: x.author, issue.fields.comment.comments)
candidates = set(commentors)
candidates.add(reporter)
candidates = list(candidates)
print("JIRA is unassigned, choose assignee")
for idx, author in enumerate(candidates):
annotations = ["Reporter"] if author == reporter else []
if author in commentors:
annotations.append("Commentor")
print("[%d] %s (%s)" % (idx, author.displayName, ",".join(annotations)))
assignee = raw_input("Enter number of user to assign to (blank to leave unassigned):")
if assignee == "":
return None
else:
assignee = candidates[int(assignee)]
asf_jira.assign_issue(issue.key, assignee.key)
return assignee
while True:
try:
reporter = issue.fields.reporter
commentors = map(lambda x: x.author, issue.fields.comment.comments)
candidates = set(commentors)
candidates.add(reporter)
candidates = list(candidates)
print("JIRA is unassigned, choose assignee")
for idx, author in enumerate(candidates):
if author.key == "apachespark":
continue
annotations = ["Reporter"] if author == reporter else []
if author in commentors:
annotations.append("Commentor")
print("[%d] %s (%s)" % (idx, author.displayName, ",".join(annotations)))
raw_assignee = raw_input(
"Enter number of user, or userid, to assign to (blank to leave unassigned):")
if raw_assignee == "":
return None
else:
try:
id = int(raw_assignee)
assignee = candidates[id]
except:
# assume it's a user id, and try to assign (might fail, we just prompt again)
assignee = asf_jira.user(raw_assignee)
asf_jira.assign_issue(issue.key, assignee.key)
return assignee
except:
traceback.print_exc()
print("Error assigning JIRA, try again (or leave blank and fix manually)")


def resolve_jira_issues(title, merge_branches, comment):
Expand Down

0 comments on commit 5ae3333

Please sign in to comment.