-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make hyphen optional for prerelease suffix #130
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing framework#133 adds some simple regex tests and instructions for running them. Currently, they are crafted strictly towards SemVer 2.0, so the unit tests would need to be adjusted slightly to accommodate an optional hyphen for prerelease suffix. Can we have it all?Is there any way we could achieve consistency between Hubcap + db-core and have strict SemVer for dbt packages and follow PEP 440 version strings for dbt adapters? Converting versions between PyPI and semver provides some useful commentary and code. You can see how the
|
@@ -12,7 +12,7 @@ | |||
def parse_semver_tag(tag): | |||
'''use regexes to parse the semver tag into groups''' | |||
# regex taken from official SEMVER documentation site |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this regex now slightly deviate from the official site? Or had it moved forward and we hadn't moved with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex in the main
branch currently matches the "named groups" regular expression in SemVer 2.0.0 precisely:
^(?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-]+)*))?$
That regex has not changed (and probably will not change within SemVer 2.x).
This PR just adds a single character change that allows for the dash prefix for pre-releases to be optional:
This would to allow for dbt package versions to have greater overlap with PEP 440 even though SemVer 2.0.0 doesn't allow it to be optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so my point is that if it's no longer the official SEMVER regex, we should update the comment to say something like "based on the SEMVER regex but with tweaks for PEP compatibility"
It also makes me wonder if we should be using these packages, rather than our own regex: from semver import Version as SemVersion
from packaging.version import Version as PyPIVersion
def parse_semver_tag(tag):
version = SemVersion(tag) or PyPIVersion(tag) # probably needs to be try/except
return str(version) That's a bigger lift than what we're trying to unblock in this PR. |
resolves #129
Not sure how to test this! It's been a little while since I did anything in this repo :)