Skip to content

Commit

Permalink
Improve _is_backport
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 14, 2024
1 parent adfb5e2 commit 78ff244
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ flake8 = "^7"
mypy = "^1.5"
pytest-cov = "^5.0.0"

[tool.black]
line-length = 88

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
16 changes: 8 additions & 8 deletions tagbot/action/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,24 @@ def _previous_release(self, version_tag: str) -> Optional[GitRelease]:
def _is_backport(self, version: str) -> bool:
"""Determine whether or not the version is a backport."""
try:
# Regular expression to match version tags with or without prefix
version_pattern = re.compile(r"^(.*[-v]?)(\d+\.\d+\.\d+)$")
version_pattern = re.compile(
r"^(.*?)[-v]?(\d+\.\d+\.\d+(?:\.\d+)*)(?:[-+].+)?$"
)

# Extract the version number from the input
# Extract any package name prefix and version number from the input
match = version_pattern.match(version)
if not match:
raise ValueError("Invalid version format: ${version}")

# Extract the base version without the 'v' prefix
raise ValueError(f"Invalid version format: {version}")
package_name = match.group(1)
cur_ver = VersionInfo.parse(match.group(2))
package_name = match.group(1).strip("-v")

for r in self._repo._repo.get_releases():
tag_match = version_pattern.match(r.tag_name)
if not tag_match:
continue

tag_package_name = tag_match.group(1).strip("-v")
tag_package_name = tag_match.group(1)

if tag_package_name != package_name:
continue

Expand Down

0 comments on commit 78ff244

Please sign in to comment.