Skip to content

Commit

Permalink
enable markdown output for jira plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Sandro Bonazzola <[email protected]>
  • Loading branch information
sandrobonazzola committed Sep 8, 2023
1 parent e6054d9 commit 41e93a1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions did/plugins/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,32 @@
class Issue(object):
""" Jira issue investigator """

def __init__(self, issue=None, prefix=None):
def __init__(self, issue=None, parent=None):
""" Initialize issue """
if issue is None:
return
self.parent = parent
self.options = parent.options
self.issue = issue
self.key = issue["key"]
self.summary = issue["fields"]["summary"]
self.comments = issue["fields"]["comment"]["comments"]
matched = re.match(r"(\w+)-(\d+)", self.key)
self.identifier = matched.groups()[1]
if prefix is not None:
self.prefix = prefix
if parent.prefix is not None:
self.prefix = parent.prefix
else:
self.prefix = matched.groups()[0]

def __str__(self):
""" Jira key and summary for displaying """
if self.options.format == "md":
return "[{0}-{1}]({2}) - {3}".format(
self.prefix,
self.identifier,
f"{self.parent.url}/browse/{self.issue['key']}",
self.summary
)
return "{0}-{1} - {2}".format(
self.prefix, self.identifier, self.summary)

Expand Down Expand Up @@ -168,7 +177,10 @@ def search(query, stats):
if len(issues) >= data["total"]:
break
# Return the list of issue objects
return [Issue(issue, prefix=stats.parent.prefix) for issue in issues]
return [
Issue(issue, parent=stats.parent)
for issue in issues
]

def updated(self, user, options):
""" True if the issue was commented by given user """
Expand Down

0 comments on commit 41e93a1

Please sign in to comment.