Skip to content

Commit

Permalink
Make it easier to debug version numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Jul 21, 2024
1 parent 1210ee8 commit 41c42b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/websockets/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def get_version(tag: str) -> str:
else:
description_re = r"[0-9.]+-([0-9]+)-(g[0-9a-f]{7,}(?:-dirty)?)"
match = re.fullmatch(description_re, description)
assert match is not None
if match is None:
raise ValueError(f"Unexpected git description: {description}")
distance, remainder = match.groups()
remainder = remainder.replace("-", ".") # required by PEP 440
return f"{tag}.dev{distance}+{remainder}"
Expand All @@ -75,7 +76,8 @@ def get_commit(tag: str, version: str) -> str:
# Extract commit from version, falling back to tag if not available.
version_re = r"[0-9.]+\.dev[0-9]+\+g([0-9a-f]{7,}|unknown)(?:\.dirty)?"
match = re.fullmatch(version_re, version)
assert match is not None
if match is None:
raise ValueError(f"Unexpected version: {version}")
(commit,) = match.groups()
return tag if commit == "unknown" else commit

Expand Down

0 comments on commit 41c42b8

Please sign in to comment.