Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Fix mapping of Type: Feature Request to New Feature issue type in Jira (
Browse files Browse the repository at this point in the history
#32)

* Fix mapping of Type: Feature Request to New Feature in Jira

* Add constant for New Feature issue type
  • Loading branch information
tom-borcin authored Aug 2, 2022
1 parent fa087bd commit 8e0c4e4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sync_issues_to_jira/sync_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import tempfile
import time

# 10101 is ID for New Feature issue type in Jira.
JIRA_NEW_FEATURE_TYPE_ID = 10101


def handle_issue_opened(jira, event):
print('Creating new JIRA issue for new GitHub issue')
Expand All @@ -39,7 +42,7 @@ def handle_issue_edited(jira, event):
fields = {
"description": _get_description(gh_issue),
"summary": _get_summary(gh_issue),
}
}

_update_components_field(jira, fields, issue)

Expand Down Expand Up @@ -137,6 +140,7 @@ def handle_comment_deleted(jira, event):
jira_issue = _find_jira_issue(jira, event["issue"], True)
jira.add_comment(jira_issue.id, "@%s deleted [GitHub issue comment|%s]" % (gh_comment["user"]["login"], gh_comment["html_url"]))


def _check_issue_label(label):
"""
Ignore labels that start with "Status:" and "Resolution:". These labels are
Expand All @@ -145,9 +149,10 @@ def _check_issue_label(label):
ignore_prefix = ("status:", "resolution:")
if label.lower().startswith(ignore_prefix):
return None

return label


def _update_link_resolved(jira, gh_issue, jira_issue):
"""
Update the 'resolved' status of the remote "synced from" link, based on the
Expand Down Expand Up @@ -339,12 +344,12 @@ def _update_components_field(jira, fields, existing_issue=None):

print("Setting components field")

fields["components"] = [{"name" : component}]
fields["components"] = [{"name": component}]
# keep any existing components as well
if existing_issue:
for component in existing_issue.fields.components:
if component.name != component:
fields["components"].append({"name" : component.name})
fields["components"].append({"name": component.name})


def _get_jira_issue_type(jira, gh_issue):
Expand All @@ -360,6 +365,10 @@ def _get_jira_issue_type(jira, gh_issue):
issue_types = jira.issue_types()

for gh_label in gh_labels:
# Type: Feature Request label should match New Feature issue type in Jira
if gh_label == 'Type: Feature Request':
print('GitHub label is \'Type: Feature Request\'. Mapping to New Feature Jira issue type')
return {"id": JIRA_NEW_FEATURE_TYPE_ID} # JIRA API needs JSON here
for issue_type in issue_types:
type_name = issue_type.name.lower()
if gh_label.lower() in [type_name, "type: %s" % (type_name,)]:
Expand Down

0 comments on commit 8e0c4e4

Please sign in to comment.