26
26
import tempfile
27
27
import time
28
28
29
+ # 10101 is ID for New Feature issue type in Jira.
30
+ JIRA_NEW_FEATURE_TYPE_ID = 10101
31
+
29
32
30
33
def handle_issue_opened (jira , event ):
31
34
print ('Creating new JIRA issue for new GitHub issue' )
@@ -39,7 +42,7 @@ def handle_issue_edited(jira, event):
39
42
fields = {
40
43
"description" : _get_description (gh_issue ),
41
44
"summary" : _get_summary (gh_issue ),
42
- }
45
+ }
43
46
44
47
_update_components_field (jira , fields , issue )
45
48
@@ -137,6 +140,7 @@ def handle_comment_deleted(jira, event):
137
140
jira_issue = _find_jira_issue (jira , event ["issue" ], True )
138
141
jira .add_comment (jira_issue .id , "@%s deleted [GitHub issue comment|%s]" % (gh_comment ["user" ]["login" ], gh_comment ["html_url" ]))
139
142
143
+
140
144
def _check_issue_label (label ):
141
145
"""
142
146
Ignore labels that start with "Status:" and "Resolution:". These labels are
@@ -145,9 +149,10 @@ def _check_issue_label(label):
145
149
ignore_prefix = ("status:" , "resolution:" )
146
150
if label .lower ().startswith (ignore_prefix ):
147
151
return None
148
-
152
+
149
153
return label
150
154
155
+
151
156
def _update_link_resolved (jira , gh_issue , jira_issue ):
152
157
"""
153
158
Update the 'resolved' status of the remote "synced from" link, based on the
@@ -339,12 +344,12 @@ def _update_components_field(jira, fields, existing_issue=None):
339
344
340
345
print ("Setting components field" )
341
346
342
- fields ["components" ] = [{"name" : component }]
347
+ fields ["components" ] = [{"name" : component }]
343
348
# keep any existing components as well
344
349
if existing_issue :
345
350
for component in existing_issue .fields .components :
346
351
if component .name != component :
347
- fields ["components" ].append ({"name" : component .name })
352
+ fields ["components" ].append ({"name" : component .name })
348
353
349
354
350
355
def _get_jira_issue_type (jira , gh_issue ):
@@ -360,6 +365,10 @@ def _get_jira_issue_type(jira, gh_issue):
360
365
issue_types = jira .issue_types ()
361
366
362
367
for gh_label in gh_labels :
368
+ # Type: Feature Request label should match New Feature issue type in Jira
369
+ if gh_label == 'Type: Feature Request' :
370
+ print ('GitHub label is \' Type: Feature Request\' . Mapping to New Feature Jira issue type' )
371
+ return {"id" : JIRA_NEW_FEATURE_TYPE_ID } # JIRA API needs JSON here
363
372
for issue_type in issue_types :
364
373
type_name = issue_type .name .lower ()
365
374
if gh_label .lower () in [type_name , "type: %s" % (type_name ,)]:
0 commit comments