@@ -214,14 +214,33 @@ def fix_version_from_branch(branch, versions):
214
214
return filter (lambda x : x .name .startswith (branch_ver ), versions )[- 1 ]
215
215
216
216
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 = "" ):
222
218
asf_jira = jira .client .JIRA ({'server' : JIRA_API_BASE },
223
219
basic_auth = (JIRA_USERNAME , JIRA_PASSWORD ))
224
220
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\n assignee\t %s\n status\t \t %s\n url\t \t %s/%s\n " % (
242
+ cur_summary , cur_assignee , cur_status , JIRA_BASE , jira_id ))
243
+
225
244
versions = asf_jira .project_versions ("SPARK" )
226
245
versions = sorted (versions , key = lambda x : x .name , reverse = True )
227
246
versions = filter (lambda x : x .raw ['released' ] is False , versions )
@@ -239,44 +258,28 @@ def get_version_json(version_str):
239
258
default_fix_versions = filter (lambda x : x != v , default_fix_versions )
240
259
default_fix_versions = "," .join (default_fix_versions )
241
260
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 ("," )
243
265
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
253
268
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 )
261
270
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\n assignee\t %s\n status\t \t %s\n url\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 )
267
274
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 )
272
276
273
- jira_fix_versions = map (lambda v : get_version_json (v ), fix_versions )
274
277
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 )
278
280
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 )
280
283
281
284
282
285
branches = get_json ("%s/branches" % GITHUB_API_BASE )
@@ -337,7 +340,7 @@ def get_version_json(version_str):
337
340
if JIRA_USERNAME and JIRA_PASSWORD :
338
341
continue_maybe ("Would you like to update an associated JIRA?" )
339
342
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 )
341
344
else :
342
345
print "JIRA_USERNAME and JIRA_PASSWORD not set"
343
346
print "Exiting without trying to close the associated JIRA."
0 commit comments