Repository: spark
Updated Branches:
  refs/heads/master 4371466b3 -> 5ae333391


[SPARK-23044] Error handling for jira assignment

## 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 <iras...@cloudera.com>

Closes #20236 from squito/SPARK-23044.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/5ae33339
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/5ae33339
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/5ae33339

Branch: refs/heads/master
Commit: 5ae333391bd73331b5b90af71a3de52cdbb24109
Parents: 4371466
Author: Imran Rashid <iras...@cloudera.com>
Authored: Tue Jan 16 16:25:10 2018 -0800
Committer: Marcelo Vanzin <van...@cloudera.com>
Committed: Tue Jan 16 16:25:10 2018 -0800

----------------------------------------------------------------------
 dev/merge_spark_pr.py | 50 +++++++++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/5ae33339/dev/merge_spark_pr.py
----------------------------------------------------------------------
diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py
index 57ca840..6b244d8 100755
--- a/dev/merge_spark_pr.py
+++ b/dev/merge_spark_pr.py
@@ -30,6 +30,7 @@ import os
 import re
 import subprocess
 import sys
+import traceback
 import urllib2
 
 try:
@@ -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):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to