Skip to content
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

Get prerelease packages when specifically requested #4295

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/dbt/deps/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ def resolved(self) -> RegistryPinnedPackage:
raise DependencyException(new_msg) from e

available = registry.get_available_versions(self.package)
prerelease_version_specified = any(
bool(version.prerelease) for version in self.versions
)
installable = semver.filter_installable(
available,
self.install_prerelease
self.install_prerelease or prerelease_version_specified
)
available_latest = installable[-1]

Expand Down
30 changes: 30 additions & 0 deletions test/unit/test_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,36 @@ def test_get_version_latest_prelease_false(self):
self.assertEqual(c_pinned.get_version_latest(), '0.1.3')
self.assertEqual(c_pinned.source_type(), 'hub')

def test_get_version_prerelease_explicitly_requested(self):
a_contract = RegistryPackage(
package='dbt-labs-test/a',
version='0.1.4a1',
install_prerelease=None
)

a = RegistryUnpinnedPackage.from_contract(a_contract)

self.assertEqual(a.package, 'dbt-labs-test/a')
self.assertEqual(
a.versions,
[
VersionSpecifier(
build=None,
major='0',
matcher='=',
minor='1',
patch='4',
prerelease='a1',
),
]
)

a_pinned = a.resolved()
self.assertEqual(a_pinned.package, 'dbt-labs-test/a')
self.assertEqual(a_pinned.version, '0.1.4a1')
self.assertEqual(a_pinned.get_version_latest(), '0.1.4a1')
self.assertEqual(a_pinned.source_type(), 'hub')

class MockRegistry:
def __init__(self, packages):
self.packages = packages
Expand Down