Add a more specific function for shas
This commit is contained in:
parent
c512512b49
commit
c713c5567f
@ -4207,8 +4207,7 @@ def _specs_with_commits(spec):
|
||||
" does not meet commit syntax requirements."
|
||||
)
|
||||
|
||||
# TODO probably want a more specific function just for sha validation
|
||||
assert vn.is_git_version(spec.variants["commit"].value), invalid_commit_msg
|
||||
assert vn.is_git_commit_sha(spec.variants["commit"].value), invalid_commit_msg
|
||||
|
||||
# Specs with GitVersions
|
||||
# - must have a commit variant, or add it here
|
||||
|
@ -20,6 +20,7 @@
|
||||
VersionError,
|
||||
VersionLookupError,
|
||||
infinity_versions,
|
||||
is_git_commit_sha,
|
||||
is_git_version,
|
||||
)
|
||||
from .version_types import (
|
||||
@ -58,6 +59,7 @@
|
||||
"any_version",
|
||||
"from_string",
|
||||
"infinity_versions",
|
||||
"is_git_commit_sha",
|
||||
"is_git_version",
|
||||
"ver",
|
||||
]
|
||||
|
@ -23,11 +23,14 @@
|
||||
STRING_TO_PRERELEASE = {"alpha": ALPHA, "beta": BETA, "rc": RC, "final": FINAL}
|
||||
|
||||
|
||||
def is_git_commit_sha(string: str) -> bool:
|
||||
return len(string) == 40 and bool(COMMIT_VERSION.match(string))
|
||||
|
||||
|
||||
def is_git_version(string: str) -> bool:
|
||||
return (
|
||||
string.startswith("git.")
|
||||
or len(string) == 40
|
||||
and bool(COMMIT_VERSION.match(string))
|
||||
or is_git_commit_sha(string)
|
||||
or "=" in string[1:]
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user