-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feature/deps-regex-semver #5370
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
kind: Under the Hood | ||
body: Added the suggested RegEx to check the SemVer string within a package dependency | ||
and improved invalid version error handling. | ||
time: 2022-06-13T17:07:03.773668-05:00 | ||
custom: | ||
Author: fivetran-joemarkiewicz | ||
Issue: "5201" | ||
PR: "5370" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,9 @@ class VersionSpecification(dbtClassMixin): | |
|
||
|
||
_MATCHERS = r"(?P<matcher>\>=|\>|\<|\<=|=)?" | ||
_NUM_NO_LEADING_ZEROS = r"(0|[1-9][0-9]*)" | ||
_NUM_NO_LEADING_ZEROS = r"(0|[1-9]\d*)" | ||
_ALPHA = r"[0-9A-Za-z-]*" | ||
_ALPHA_NO_LEADING_ZEROS = r"(0|[1-9A-Za-z-][0-9A-Za-z-]*)" | ||
_ALPHA_NO_LEADING_ZEROS = r"(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)" | ||
|
||
_BASE_VERSION_REGEX = r""" | ||
(?P<major>{num_no_leading_zeros})\. | ||
|
@@ -95,7 +95,7 @@ def from_version_string(cls, version_string): | |
|
||
if not match: | ||
raise dbt.exceptions.SemverException( | ||
'Could not parse version "{}"'.format(version_string) | ||
'"{}" is not a valid semantic version.'.format(version_string) | ||
) | ||
|
||
matched = {k: v for k, v in match.groupdict().items() if v is not None} | ||
|
@@ -427,6 +427,15 @@ def resolve_to_specific_version(requested_range, available_versions): | |
return max_version_string | ||
|
||
|
||
def semver_regex_versioning(versions: List[str]) -> bool: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just for testing? Can we move it into the test file if that's the case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just for testing the various version types. I moved it into the testing file as that does make a lot more sense 😄 |
||
for version_string in versions: | ||
try: | ||
VersionSpecifier.from_version_string(version_string) | ||
except Exception: | ||
return False | ||
return True | ||
|
||
|
||
def filter_installable(versions: List[str], install_prerelease: bool) -> List[str]: | ||
installable = [] | ||
installable_dict = {} | ||
|
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.
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.
Added this change in the most recent commit. Thanks!