Skip to content

Commit

Permalink
Add --unreleased-only
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 25, 2019
1 parent a069edc commit ea75dc6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/matyan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def prepare_changelog(
between: str = None,
unique_commit_messages: bool = False,
headings_only: bool = False,
unreleased_only: bool = False,
path: str = None
) -> Dict[
str, Dict[str, Dict[str, Union[str, Dict[str, Union[str, str]]]]]
Expand Down Expand Up @@ -401,6 +402,7 @@ def prepare_releases_changelog(
between: str = None,
unique_commit_messages: bool = False,
headings_only: bool = False,
unreleased_only: bool = False,
path: str = None
) -> Dict[
str, Dict[str, Dict[str, Union[str, Dict[str, Union[str, str]]]]]
Expand Down Expand Up @@ -476,6 +478,8 @@ def prepare_releases_changelog(
branch_types.update({ticket_number: branch_type})

if headings_only:
if unreleased_only:
return {UNRELEASED: releases_tree.get(UNRELEASED, {})}
return releases_tree

# Now go through commits
Expand Down Expand Up @@ -609,6 +613,9 @@ def prepare_releases_changelog(
'title': commit_message,
}

if unreleased_only:
return {UNRELEASED: releases_tree.get(UNRELEASED, {})}

return releases_tree


Expand Down Expand Up @@ -741,6 +748,7 @@ def generate_changelog(between: str = None,
show_releases: bool = False,
latest_release: bool = False,
headings_only: bool = False,
unreleased_only: bool = False,
path: str = None) -> str:
"""Generate changelog (markdown format)."""

Expand All @@ -762,6 +770,7 @@ def generate_changelog(between: str = None,
between=between,
unique_commit_messages=True,
headings_only=headings_only,
unreleased_only=unreleased_only,
path=path
)
for branch_type, tickets in tree.items():
Expand Down Expand Up @@ -812,6 +821,7 @@ def generate_changelog(between: str = None,
between=between,
unique_commit_messages=True,
headings_only=headings_only,
unreleased_only=unreleased_only,
path=path
)

Expand Down Expand Up @@ -905,20 +915,29 @@ def generate_changelog_cli() -> Type[None]:
action='store_true',
help="Generate headings only (no commit messages, only branch titles)",
)
parser.add_argument(
'--unreleased-only',
dest="unreleased_only",
default=False,
action='store_true',
help="Show unreleased only",
)
args = parser.parse_args(sys.argv[1:])
between = args.between if validate_between(args.between) else None
include_other = not args.no_other
show_releases = args.show_releases
latest_release = args.latest_release
headings_only = args.headings_only
unreleased_only = args.unreleased_only

print(
generate_changelog(
between=between,
include_other=include_other,
show_releases=show_releases,
latest_release=latest_release,
headings_only=headings_only
headings_only=headings_only,
unreleased_only=unreleased_only
)
)

Expand Down

0 comments on commit ea75dc6

Please sign in to comment.