Skip to content

Commit

Permalink
fix: don't use commit_subject for tag pattern matching (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Jul 25, 2022
1 parent 41974a0 commit ac3f11e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions semantic_release/history/__init__.py
Expand Up @@ -36,10 +36,15 @@ def get_pattern_with_commit_subject(pattern):

def get_version_pattern():
prerelease_pattern = get_prerelease_pattern()
return get_pattern_with_commit_subject(f"(\d+\.\d+\.\d+({prerelease_pattern})?)")
return f"(\d+\.\d+\.\d+({prerelease_pattern})?)"


def get_release_version_pattern():
prerelease_pattern = get_prerelease_pattern()
return f"v?(\d+\.\d+\.\d+(?!.*{prerelease_pattern}))"


def get_commit_release_version_pattern():
prerelease_pattern = get_prerelease_pattern()
return get_pattern_with_commit_subject(
f"v?(\d+\.\d+\.\d+(?!.*{prerelease_pattern}))"
Expand Down Expand Up @@ -376,7 +381,7 @@ def get_previous_release_version(version: str) -> Optional[str]:
:param version: A string with the version number.
:return: A string with the previous version number.
"""
release_version_pattern = get_release_version_pattern()
release_version_pattern = get_commit_release_version_pattern()

found_version = False
for commit_hash, commit_message in get_commit_log():
Expand Down Expand Up @@ -404,7 +409,7 @@ def get_current_release_version_by_commits() -> str:
:return: A string with the current version number.
"""
release_version_re = re.compile(get_release_version_pattern())
release_version_re = re.compile(get_commit_release_version_pattern())

for commit_hash, commit_message in get_commit_log():
logger.debug(f"Checking commit {commit_hash}")
Expand Down

0 comments on commit ac3f11e

Please sign in to comment.