Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4085 from pypeclub/bugfix/regex-to-determine-staging
Browse files Browse the repository at this point in the history
Igniter: fix regex to match semver better
  • Loading branch information
antirotor authored Nov 11, 2022
2 parents 5380648 + 69f4253 commit d1ba290
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion igniter/bootstrap_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class OpenPypeVersion(semver.VersionInfo):
"""
staging = False
path = None
_VERSION_REGEX = re.compile(r"(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?") # noqa: E501
# this should match any string complying with https://semver.org/
_VERSION_REGEX = re.compile(r"(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>[a-zA-Z\d\-.]*))?(?:\+(?P<buildmetadata>[a-zA-Z\d\-.]*))?") # noqa: E501
_installed_version = None

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -211,6 +212,8 @@ def version_in_str(string: str) -> Union[None, OpenPypeVersion]:
OpenPypeVersion: of detected or None.
"""
# strip .zip ext if present
string = re.sub(r"\.zip$", "", string, flags=re.IGNORECASE)
m = re.search(OpenPypeVersion._VERSION_REGEX, string)
if not m:
return None
Expand Down

0 comments on commit d1ba290

Please sign in to comment.