Tushar Gupta has proposed merging ~tushar5526/launchpad:fix-preload-data-for-recipes into launchpad:master.
Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~tushar5526/launchpad/+git/launchpad/+merge/486572 -- Your team Launchpad code reviewers is requested to review the proposed merge of ~tushar5526/launchpad:fix-preload-data-for-recipes into launchpad:master.
diff --git a/lib/lp/charms/model/charmrecipe.py b/lib/lp/charms/model/charmrecipe.py index dfea776..2efc498 100644 --- a/lib/lp/charms/model/charmrecipe.py +++ b/lib/lp/charms/model/charmrecipe.py @@ -1221,7 +1221,11 @@ class CharmRecipeSet: GenericGitCollection.preloadDataForRepositories(repositories) git_refs = GitRef.findByReposAndPaths( - [(recipe.git_repository, recipe.git_path) for recipe in recipes] + [ + (recipe.git_repository, recipe.git_path) + for recipe in recipes + if recipe.git_repository + ] ) for recipe in recipes: git_ref = git_refs.get((recipe.git_repository, recipe.git_path)) diff --git a/lib/lp/charms/tests/test_charmrecipebuild.py b/lib/lp/charms/tests/test_charmrecipebuild.py index 8d13837..4b59b37 100644 --- a/lib/lp/charms/tests/test_charmrecipebuild.py +++ b/lib/lp/charms/tests/test_charmrecipebuild.py @@ -820,6 +820,17 @@ class TestCharmRecipeBuildSet(TestCaseWithFactory): ), ) + def test_getByBuildFarmJob_works_for_remote_repositories(self): + build = self.factory.makeCharmRecipeBuild( + git_repository_url="https://foo.git", git_path="main" + ) + self.assertEqual( + build, + getUtility(ICharmRecipeBuildSet).getByBuildFarmJob( + build.build_farm_job + ), + ) + def test_getByBuildFarmJob_returns_None_when_missing(self): bpb = self.factory.makeBinaryPackageBuild() self.assertIsNone( @@ -829,7 +840,12 @@ class TestCharmRecipeBuildSet(TestCaseWithFactory): ) def test_getByBuildFarmJobs_works(self): - builds = [self.factory.makeCharmRecipeBuild() for i in range(10)] + builds = [self.factory.makeCharmRecipeBuild() for i in range(10)] + [ + self.factory.makeCharmRecipeBuild( + git_repository_url="https://foo.git", git_path="main" + ) + for i in range(10) + ] self.assertContentEqual( builds, getUtility(ICharmRecipeBuildSet).getByBuildFarmJobs( diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py index 1574c4b..d23c481 100644 --- a/lib/lp/testing/factory.py +++ b/lib/lp/testing/factory.py @@ -6753,6 +6753,8 @@ class LaunchpadObjectFactory(ObjectFactory): date_created=DEFAULT, use_fetch_service=False, fetch_service_policy=FetchServicePolicy.STRICT, + git_repository_url=None, + git_path=None, ): """Make a new charm recipe.""" if registrant is None: @@ -6782,7 +6784,7 @@ class LaunchpadObjectFactory(ObjectFactory): ) if name is None: name = self.getUniqueUnicode("charm-name") - if git_ref is None: + if git_repository_url is None and git_ref is None: git_ref = self.makeGitRefs()[0] recipe = getUtility(ICharmRecipeSet).new( registrant=registrant, @@ -6803,6 +6805,8 @@ class LaunchpadObjectFactory(ObjectFactory): date_created=date_created, use_fetch_service=use_fetch_service, fetch_service_policy=fetch_service_policy, + git_repository_url=git_repository_url, + git_path=git_path, ) if is_stale is not None: removeSecurityProxy(recipe).is_stale = is_stale
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp