@@ -33,11 +33,13 @@ def make_snapshot_distro(monkeypatch):
3333 snapshot = {
3434 "snapshot_package" : {
3535 "url" : "https://github.com/example/snapshot-package-release.git" ,
36+ "repository" : "https://github.com/example/snapshot-package.git" ,
3637 "version" : "1.0.0" ,
3738 "tag" : "release/rolling/snapshot_package/1.0.0-1" ,
3839 },
3940 "snapshot_dependency" : {
4041 "url" : "https://github.com/example/snapshot-dependency-release.git" ,
42+ "repository" : "https://github.com/example/snapshot-dependency.git" ,
4143 "version" : "1.0.0" ,
4244 "tag" : "release/rolling/snapshot_dependency/1.0.0-1" ,
4345 },
@@ -83,6 +85,10 @@ def test_snapshot_package_xml_and_dependencies_do_not_follow_live_rosdistro(
8385 "release/rolling/snapshot_package/1.0.0-1" ,
8486 "tag" ,
8587 )
88+ assert (
89+ distro .get_repository_url ("snapshot_package" )
90+ == "https://github.com/example/snapshot-package"
91+ )
8692 assert distro .get_version ("snapshot_package" ) == "1.0.0"
8793 assert "<version>1.0.0</version>" in package_xml_content
8894 assert "snapshot_dependency" in package_xml_content
@@ -173,6 +179,9 @@ def test_snapshot_metadata_generates_dependency_required_by_pinned_source(
173179 "name" : "ros2-snapshot-package" ,
174180 "version" : "1.0.0" ,
175181 }
182+ assert output ["about" ]["repository" ] == (
183+ "https://github.com/example/snapshot-package"
184+ )
176185 assert "ros2-snapshot-dependency" in output ["requirements" ]["host" ]
177186 assert "ros2-live-dependency" not in output ["requirements" ]["host" ]
178187
@@ -189,6 +198,90 @@ def test_snapshot_is_authoritative_for_package_membership(monkeypatch):
189198 }
190199
191200
201+ def test_live_repository_url_requires_upstream_source_metadata ():
202+ distro = Distro .__new__ (Distro )
203+ distro .snapshot = None
204+ distro .additional_packages_snapshot = None
205+ distro ._distro = Mock ()
206+ distro ._distro .release_packages = {
207+ "source_package" : Mock (repository_name = "source-package" ),
208+ "release_only_package" : Mock (repository_name = "release-only-package" ),
209+ "bloom_source_package" : Mock (repository_name = "bloom-source-package" ),
210+ }
211+ distro ._distro .repositories = {
212+ "source-package" : Mock (
213+ source_repository = Mock (url = "https://github.com/example/source.git" ),
214+ release_repository = Mock (
215+ url = "https://github.com/example/source-release.git"
216+ ),
217+ ),
218+ "release-only-package" : Mock (
219+ source_repository = None ,
220+ release_repository = Mock (
221+ url = "https://github.com/example/release-only-release.git"
222+ ),
223+ ),
224+ "bloom-source-package" : Mock (
225+ source_repository = Mock (
226+ url = "https://github.com/example/bloom-source-release.git"
227+ ),
228+ release_repository = Mock (
229+ url = "https://github.com/ros2-gbp/bloom-source-release.git"
230+ ),
231+ ),
232+ }
233+
234+ assert (
235+ distro .get_repository_url ("source_package" )
236+ == "https://github.com/example/source"
237+ )
238+ assert distro .get_repository_url ("release_only_package" ) is None
239+ assert (
240+ distro .get_repository_url (
241+ "release_only_package" ,
242+ [Mock (type = "repository" , url = "https://github.com/example/upstream.git" )],
243+ )
244+ == "https://github.com/example/upstream"
245+ )
246+ assert distro .get_repository_url ("bloom_source_package" ) is None
247+
248+
249+ def test_additional_package_repository_must_be_explicit ():
250+ distro = Distro .__new__ (Distro )
251+ distro .snapshot = None
252+ distro .additional_packages_snapshot = {
253+ "explicit" : {
254+ "url" : "https://github.com/example/explicit-release.git" ,
255+ "repository" : "https://github.com/example/explicit.git" ,
256+ },
257+ "source_only" : {"url" : "https://github.com/example/source-only.git" },
258+ }
259+
260+ assert (
261+ distro .get_repository_url ("explicit" ) == "https://github.com/example/explicit"
262+ )
263+ assert distro .get_repository_url ("source_only" ) is None
264+ assert (
265+ distro .get_repository_url (
266+ "source_only" ,
267+ [Mock (type = "repository" , url = "https://github.com/example/source-only.git" )],
268+ )
269+ == "https://github.com/example/source-only"
270+ )
271+ assert (
272+ distro .get_repository_url (
273+ "source_only" ,
274+ [
275+ Mock (
276+ type = "repository" ,
277+ url = "https://github.com/example/source-only-release.git" ,
278+ )
279+ ],
280+ )
281+ is None
282+ )
283+
284+
192285def test_empty_snapshot_keeps_live_rosdistro_behavior ():
193286 distro = Distro .__new__ (Distro )
194287 distro .snapshot = {}
0 commit comments