Skip to content

Commit

Permalink
chore: Fix typing and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetrr committed Mar 22, 2024
1 parent 527cf1a commit 8be7edd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def get_new_version(
prefix: str,
suffix: str,
only_increase_suffix: bool,
only_replace_prefix_with: str | None
) -> tuple[str, bool]:
only_replace_suffix_with: str | None
) -> tuple[str, str, bool]:
"""
Get the new version, involving the only_increase_suffix flag.
Expand All @@ -243,14 +243,19 @@ def get_new_version(
else:
current_version = current_version_tag.name.removeprefix(prefix)

if only_replace_prefix_with is None:
if only_replace_suffix_with is None:
next_version, has_changes = get_next_version(repo, current_version_tag, current_version)
else:
# Only replace the suffix if
# Only replace the suffix if it is present in the version, else return the current version
if current_version.endswith(f'-{suffix}'):
next_version = current_version.removesuffix(suffix) + only_replace_prefix_with
next_version = current_version.removesuffix(suffix) + only_replace_suffix_with
logger.info('Replacing suffix %s with %s', suffix, only_replace_suffix_with)
else:
next_version = current_version
logger.info(
'Suffix %s was not found in version %s, so it will not be replaced',
suffix, current_version
)
has_changes = False

logger.debug(
Expand Down

0 comments on commit 8be7edd

Please sign in to comment.