Skip to content

Commit 401224c

Browse files
committed
SPARK-4507: moved codes as before
1 parent ce89021 commit 401224c

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

dev/merge_spark_pr.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,33 @@ def fix_version_from_branch(branch, versions):
214214
return filter(lambda x: x.name.startswith(branch_ver), versions)[-1]
215215

216216

217-
def resolve_jira(title, merge_branches, comment):
218-
219-
def get_version_json(version_str):
220-
return filter(lambda v: v.name == version_str, versions)[0].raw
221-
217+
def resolve_jira_issue(merge_branches, comment, default_jira_id=""):
222218
asf_jira = jira.client.JIRA({'server': JIRA_API_BASE},
223219
basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))
224220

221+
jira_id = raw_input("Enter a JIRA id [%s]: " % default_jira_id)
222+
if jira_id == "":
223+
jira_id = default_jira_id
224+
225+
try:
226+
issue = asf_jira.issue(jira_id)
227+
except Exception as e:
228+
fail("ASF JIRA could not find %s\n%s" % (jira_id, e))
229+
230+
cur_status = issue.fields.status.name
231+
cur_summary = issue.fields.summary
232+
cur_assignee = issue.fields.assignee
233+
if cur_assignee is None:
234+
cur_assignee = "NOT ASSIGNED!!!"
235+
else:
236+
cur_assignee = cur_assignee.displayName
237+
238+
if cur_status == "Resolved" or cur_status == "Closed":
239+
fail("JIRA issue %s already has status '%s'" % (jira_id, cur_status))
240+
print ("=== JIRA %s ===" % jira_id)
241+
print ("summary\t\t%s\nassignee\t%s\nstatus\t\t%s\nurl\t\t%s/%s\n" % (
242+
cur_summary, cur_assignee, cur_status, JIRA_BASE, jira_id))
243+
225244
versions = asf_jira.project_versions("SPARK")
226245
versions = sorted(versions, key=lambda x: x.name, reverse=True)
227246
versions = filter(lambda x: x.raw['released'] is False, versions)
@@ -239,44 +258,28 @@ def get_version_json(version_str):
239258
default_fix_versions = filter(lambda x: x != v, default_fix_versions)
240259
default_fix_versions = ",".join(default_fix_versions)
241260

242-
search_jira_ids = re.findall("SPARK-[0-9]{4,5}", title)
261+
fix_versions = raw_input("Enter comma-separated fix version(s) [%s]: " % default_fix_versions)
262+
if fix_versions == "":
263+
fix_versions = default_fix_versions
264+
fix_versions = fix_versions.replace(" ", "").split(",")
243265

244-
for search_jira_id in search_jira_ids:
245-
jira_id = raw_input("Enter a JIRA id [%s]: " % search_jira_id)
246-
if jira_id == "":
247-
jira_id = search_jira_id
248-
249-
try:
250-
issue = asf_jira.issue(jira_id)
251-
except Exception as e:
252-
fail("ASF JIRA could not find %s\n%s" % (jira_id, e))
266+
def get_version_json(version_str):
267+
return filter(lambda v: v.name == version_str, versions)[0].raw
253268

254-
cur_status = issue.fields.status.name
255-
cur_summary = issue.fields.summary
256-
cur_assignee = issue.fields.assignee
257-
if cur_assignee is None:
258-
cur_assignee = "NOT ASSIGNED!!!"
259-
else:
260-
cur_assignee = cur_assignee.displayName
269+
jira_fix_versions = map(lambda v: get_version_json(v), fix_versions)
261270

262-
if cur_status == "Resolved" or cur_status == "Closed":
263-
fail("JIRA issue %s already has status '%s'" % (jira_id, cur_status))
264-
print ("=== JIRA %s ===" % jira_id)
265-
print ("summary\t\t%s\nassignee\t%s\nstatus\t\t%s\nurl\t\t%s/%s\n" % (
266-
cur_summary, cur_assignee, cur_status, JIRA_BASE, jira_id))
271+
resolve = filter(lambda a: a['name'] == "Resolve Issue", asf_jira.transitions(jira_id))[0]
272+
asf_jira.transition_issue(
273+
jira_id, resolve["id"], fixVersions=jira_fix_versions, comment=comment)
267274

268-
fix_versions = raw_input("Enter comma-separated fix version(s) [%s]: " % default_fix_versions)
269-
if fix_versions == "":
270-
fix_versions = default_fix_versions
271-
fix_versions = fix_versions.replace(" ", "").split(",")
275+
print "Succesfully resolved %s with fixVersions=%s!" % (jira_id, fix_versions)
272276

273-
jira_fix_versions = map(lambda v: get_version_json(v), fix_versions)
274277

275-
resolve = filter(lambda a: a['name'] == "Resolve Issue", asf_jira.transitions(jira_id))[0]
276-
asf_jira.transition_issue(
277-
jira_id, resolve["id"], fixVersions=jira_fix_versions, comment=comment)
278+
def resolve_jira_issues(title, merge_branches, comment):
279+
jira_ids = re.findall("SPARK-[0-9]{4,5}", title)
278280

279-
print "Succesfully resolved %s with fixVersions=%s!" % (jira_id, fix_versions)
281+
for jira_id in jira_ids:
282+
resolve_jira_issue(merge_branches, comment, jira_id)
280283

281284

282285
branches = get_json("%s/branches" % GITHUB_API_BASE)
@@ -337,7 +340,7 @@ def get_version_json(version_str):
337340
if JIRA_USERNAME and JIRA_PASSWORD:
338341
continue_maybe("Would you like to update an associated JIRA?")
339342
jira_comment = "Issue resolved by pull request %s\n[%s/%s]" % (pr_num, GITHUB_BASE, pr_num)
340-
resolve_jira(title, merged_refs, jira_comment)
343+
resolve_jira_issues(title, merged_refs, jira_comment)
341344
else:
342345
print "JIRA_USERNAME and JIRA_PASSWORD not set"
343346
print "Exiting without trying to close the associated JIRA."

0 commit comments

Comments
 (0)