Skip to content

Commit

Permalink
Convert Pagure description from Markdown to Jira format
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Jan 8, 2021
1 parent cd1be5a commit a9bc219
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions sync2jira/intermediary.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
from datetime import datetime
import re

import pypandoc


def _md_to_jira(markdown):
"""Convert Markdown to Jira"""
return pypandoc.convert_text(markdown, 'jira', format='markdown').rstrip('\n')


class Issue(object):
"""Issue Intermediary object"""
Expand Down Expand Up @@ -75,7 +82,7 @@ def from_pagure(cls, upstream, issue, config):
comment['date_created'] = datetime.fromtimestamp(float(comment['date_created']))
comments.append({
'author': comment['user']['name'],
'body': comment['comment'],
'body': _md_to_jira(comment['comment']),
'name': comment['user']['name'],
'id': comment['id'],
'date_created': comment['date_created'],
Expand All @@ -99,7 +106,7 @@ def from_pagure(cls, upstream, issue, config):
tags=issue['tags'],
fixVersion=[issue['milestone']],
priority=issue['priority'],
content=issue['content'],
content=_md_to_jira(issue['content']),
reporter=issue['user'],
assignee=issue['assignee'],
status=issue['status'],
Expand Down Expand Up @@ -221,7 +228,7 @@ def from_pagure(self, upstream, pr, suffix, config):
float(comment['date_created']))
comments.append({
'author': comment['user']['name'],
'body': comment['comment'],
'body': _md_to_jira(comment['comment']),
'name': comment['user']['name'],
'id': comment['id'],
'date_created': comment['date_created'],
Expand All @@ -246,7 +253,7 @@ def from_pagure(self, upstream, pr, suffix, config):
# tags=issue['labels'],
# fixVersion=[issue['milestone']],
priority=None,
content=pr['initial_comment'],
content=_md_to_jira(pr['initial_comment']),
reporter=pr['user']['fullname'],
assignee=pr['assignee'],
status=pr['status'],
Expand Down

0 comments on commit a9bc219

Please sign in to comment.