Skip to content

Commit e791bf3

Browse files
jira: enable markdown output
Signed-off-by: Sandro Bonazzola <[email protected]>
1 parent e6054d9 commit e791bf3

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

did/plugins/jira.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,32 @@
112112
class Issue(object):
113113
""" Jira issue investigator """
114114

115-
def __init__(self, issue=None, prefix=None):
115+
def __init__(self, issue=None, parent=None):
116116
""" Initialize issue """
117117
if issue is None:
118118
return
119+
self.parent = parent
120+
self.options = parent.options
119121
self.issue = issue
120122
self.key = issue["key"]
121123
self.summary = issue["fields"]["summary"]
122124
self.comments = issue["fields"]["comment"]["comments"]
123125
matched = re.match(r"(\w+)-(\d+)", self.key)
124126
self.identifier = matched.groups()[1]
125-
if prefix is not None:
126-
self.prefix = prefix
127+
if parent.prefix is not None:
128+
self.prefix = parent.prefix
127129
else:
128130
self.prefix = matched.groups()[0]
129131

130132
def __str__(self):
131133
""" Jira key and summary for displaying """
134+
if self.options.format == "md":
135+
return "[{0}-{1}]({2}) - {3}".format(
136+
self.prefix,
137+
self.identifier,
138+
f"{self.parent.url}/browse/{self.issue['key']}",
139+
self.summary
140+
)
132141
return "{0}-{1} - {2}".format(
133142
self.prefix, self.identifier, self.summary)
134143

@@ -168,7 +177,10 @@ def search(query, stats):
168177
if len(issues) >= data["total"]:
169178
break
170179
# Return the list of issue objects
171-
return [Issue(issue, prefix=stats.parent.prefix) for issue in issues]
180+
return [
181+
Issue(issue, parent=stats.parent)
182+
for issue in issues
183+
]
172184

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

0 commit comments

Comments
 (0)