Skip to content

Commit

Permalink
Fix pdm backend format for next_version
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyChris committed Nov 12, 2024
1 parent 8b056f6 commit c588884
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions includecontents/next_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from pdm.backend.hooks.version import scm

RELEASE_TAG = r"v(?P<version>[0-9]+(\.[0-9]+)+)"


def _major(scm_version: scm.SCMVersion) -> str:
version = scm_version.version
Expand Down Expand Up @@ -31,33 +29,18 @@ def next_version(part: str) -> str:
"""
formatter = formatters[part]
version = scm.get_version_from_scm(
".", version_formatter=formatter, tag_regex=RELEASE_TAG
".",
tag_regex=r"v(?P<version>[0-9]+(\.[0-9]+)+)",
)
if version is None:
raise ValueError("No version found in git tags")
return version


def check_version_is_release() -> str:
"""
Ensure the current version is a release version.
"""
version = scm.get_version_from_scm(".", tag_regex=RELEASE_TAG)
if version is None:
raise ValueError("No version found in git tags")
if ".dev" in version:
raise ValueError(f"Current version ({version}) is not a release version")
return version
return formatter(version)


if __name__ == "__main__":
import sys

if len(sys.argv) == 1:
print(f"{check_version_is_release()} is a release version")
sys.exit(0)

if len(sys.argv) > 2:
if len(sys.argv) != 2:
raise ValueError("Expected a single 'part' argument (major, minor, or patch)")
part = sys.argv[1] if len(sys.argv) > 1 else "patch"
if part not in formatters:
Expand Down

0 comments on commit c588884

Please sign in to comment.