Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Dec 22, 2019
1 parent 0f41089 commit 5215c95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/matyan/fetchers/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def get_instance(self) -> Jira:

def fetch_issue_data(self, issue_id: str) -> Dict[str, str]:
issue = self.instance.issue(issue_id)
return {
'title': issue['fields']['summary'],
'description': issue['fields']['description'],
}
try:
return {
'title': issue['fields']['summary'],
'description': issue['fields']['description'],
}
except TypeError as err:
return {}
15 changes: 11 additions & 4 deletions src/matyan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import re
import logging
import sys
from shutil import copyfile
from typing import Union, Dict, AnyStr, Type, Any, List
Expand Down Expand Up @@ -45,6 +46,7 @@
REGEX_PATTERN_TAG,
)

LOGGER = logging.getLogger(__name__)
DEBUG = os.environ.get('DEBUG', False)

__author__ = 'Artur Barseghyan'
Expand Down Expand Up @@ -260,10 +262,15 @@ def prepare_changelog(
fetcher_cls = FetcherRegistry.REGISTRY[settings.get('fetchDataFrom')]
fetcher = fetcher_cls()
fetcher_data = fetcher.fetch_issue_data(ticket_number)
if fetch_title:
if fetch_title and 'title' in fetcher_data:
branch_title = fetcher_data['title']
if fetch_description:
if fetch_description and 'description' in fetcher_data:
branch_description = fetcher_data['description']
elif (
settings.get('fetchDataFrom')
and settings.get('fetchDataFrom') not in FetcherRegistry.REGISTRY
):
LOGGER.debug(f"settings.get('fetchDataFrom') is not found in the registry!")

if not branch_title:
branch_title = match.group('branch_title')
Expand Down Expand Up @@ -484,9 +491,9 @@ def prepare_releases_changelog(
fetcher_cls = FetcherRegistry.REGISTRY[settings.get('fetchDataFrom')]
fetcher = fetcher_cls()
fetcher_data = fetcher.fetch_issue_data(ticket_number)
if fetch_title:
if fetch_title and 'title' in fetcher_data:
branch_title = fetcher_data['title']
if fetch_description:
if fetch_description and 'description' in fetcher_data:
branch_description = fetcher_data['description']

if not branch_title:
Expand Down

0 comments on commit 5215c95

Please sign in to comment.