Skip to content

Commit

Permalink
Fixes in rendering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 22, 2019
1 parent 0592fe8 commit b9be5d5
Showing 1 changed file with 33 additions and 19 deletions.
52 changes: 33 additions & 19 deletions src/matyan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import sys
from shutil import copyfile
from pprint import pprint
from typing import Union, Dict, AnyStr, Type, Any
import git
from git.exc import GitCommandError
Expand All @@ -30,6 +29,8 @@
REGEX_PATTERN_TAG,
)

DEBUG = os.environ.get('DEBUG', False)

__author__ = 'Artur Barseghyan'
__copyright__ = '2019 Artur Barseghyan'
__license__ = 'GPL-2.0-only OR LGPL-2.0-or-later'
Expand Down Expand Up @@ -760,11 +761,13 @@ def generate_changelog(between: str = None,
continue

# Do not add branch type if no related branches found
if tickets:
if BRANCH_TYPES.get(branch_type):
changelog.append(
"\n**{}**".format(BRANCH_TYPES.get(branch_type))
)
if not tickets:
continue

if BRANCH_TYPES.get(branch_type):
changelog.append(
"\n**{}**".format(BRANCH_TYPES.get(branch_type))
)

# Add tickets
for ticket_number, ticket_data in tickets.items():
Expand All @@ -776,8 +779,8 @@ def generate_changelog(between: str = None,
'\n' if not headings_only else ''
)
)
else:
changelog.append('')
elif not headings_only:
changelog.append('') and ticket_data.get('commits', {})

if headings_only:
continue
Expand All @@ -796,50 +799,61 @@ def generate_changelog(between: str = None,
headings_only=headings_only,
path=path
)

for release, branches in releases_tree.items():
release_label = UNRELEASED_LABEL \
if release == UNRELEASED \
else release

changelog.append("\n### {}".format(release_label))
for branch_type, tickets in branches.items():

# Skip adding orphaned commits if explicitly asked not to.
if branch_type == BRANCH_TYPE_OTHER and not include_other:
continue

# Do not add branch type if no related branches found
if tickets:
if BRANCH_TYPES.get(branch_type):
changelog.append(
"\n**{}**".format(BRANCH_TYPES.get(branch_type))
if not tickets:
continue

if branch_type != BRANCH_TYPE_OTHER:
counter = 0

if BRANCH_TYPES.get(branch_type):
changelog.append(
"\n**{}**{}".format(
BRANCH_TYPES.get(branch_type),
'\n' if branch_type == BRANCH_TYPE_OTHER else ''
)
)

# Add tickets
for ticket_number, ticket_data in tickets.items():
if branch_type != BRANCH_TYPE_OTHER:
if 'title' not in ticket_data:
continue
if 'title' not in ticket_data:
continue

if branch_type != BRANCH_TYPE_OTHER:
changelog.append(
"\n*{} {}*{}".format(
ticket_number,
ticket_data['title'],
'\n' if not headings_only else ''
''# if not headings_only else ''
)
)
else:
changelog.append('')

if headings_only:
continue

counter = 0
for commit_hash, commit_data in ticket_data['commits'].items(): # NOQA
changelog.append(
"- {} [{}]".format(
"{}- {} [{}]".format(
'\n' if counter == 0 and branch_type != BRANCH_TYPE_OTHER else '',
commit_data['title'],
commit_data['author']
)
)
counter = counter + 1

return '\n'.join(changelog)

Expand Down

0 comments on commit b9be5d5

Please sign in to comment.