Skip to content

Commit

Permalink
Improve: Exit with code 0, if no commits are found
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Aug 18, 2024
1 parent b20cfc5 commit d68d159
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tinysemver/tinysemver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
PathLike = Union[str, os.PathLike]


class NoNewCommitsError(Exception):
"""Raised when no new commits are found since the last tag."""

pass


def get_last_tag(repository_path: PathLike) -> str:
"""Retrieve the last Git tag name from the repository."""
result = subprocess.run(
Expand Down Expand Up @@ -403,7 +409,8 @@ def normalize_path(file_path: str) -> str:
print(f"Current version: {current_version[0]}.{current_version[1]}.{current_version[2]}")

commits_hashes, commits_messages = get_commits_since_tag(repository_path, last_tag)
assert len(commits_hashes), f"No new commits since the last {last_tag} tag, aborting."
if not len(commits_hashes):
raise NoNewCommitsError(f"No new commits since the last {last_tag} tag")

if verbose:
print(f"? Commits since last tag: {len(commits_hashes)}")
Expand Down Expand Up @@ -653,6 +660,9 @@ class Args:
push=args.push,
create_release=args.create_release,
)
except NoNewCommitsError as e:
print(f"! {e}")
exit(0)
except AssertionError as e:
print(f"! {e}")
exit(1)
Expand Down

0 comments on commit d68d159

Please sign in to comment.