Skip to content

Commit fb2823b

Browse files
authored
Add support for specify rev in place of tag in rosdistro_additional_recipes.yaml (#87)
1 parent 3b00c2f commit fb2823b

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

vinca/distro.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,24 @@ def get_depends(self, pkg, ignore_pkgs=None):
9494

9595
def get_released_repo(self, pkg_name):
9696
if self.snapshot and pkg_name in self.snapshot:
97-
return (
98-
self.snapshot[pkg_name].get("url", None),
99-
self.snapshot[pkg_name].get("tag", None),
100-
)
97+
98+
# In the case of snapshot, for rosdistro_additional_recipes
99+
# we also support a 'rev' field, so depending on what is available
100+
# we return either the tag or the rev, and the third argument is either 'rev' or 'tag'
101+
url = self.snapshot[pkg_name].get("url", None)
102+
if "tag" in self.snapshot[pkg_name].keys():
103+
tag_or_rev = self.snapshot[pkg_name].get("tag", None)
104+
ref_type = "tag"
105+
else:
106+
tag_or_rev = self.snapshot[pkg_name].get("rev", None)
107+
ref_type = "rev"
108+
109+
return url, tag_or_rev, ref_type
101110

102111
pkg = self._distro.release_packages[pkg_name]
103112
repo = self._distro.repositories[pkg.repository_name].release_repository
104113
release_tag = get_release_tag(repo, pkg_name)
105-
return repo.url, release_tag
114+
return repo.url, release_tag, 'tag'
106115

107116
def check_package(self, pkg_name):
108117
# If the package is in the additional_packages_snapshot, it is always considered valid
@@ -151,12 +160,13 @@ def get_package_xml_for_additional_package(self, pkg_info):
151160
raise RuntimeError(f"Cannot handle non-GitHub URL: {raw_url_base}")
152161
# Extract owner/repo
153162
owner_repo = raw_url_base.split("github.com/")[-1]
154-
tag = pkg_info.get("tag")
163+
# Use rev if available, otherwise fallback to tag
164+
ref = pkg_info.get("rev") or pkg_info.get("tag")
155165
xml_name = pkg_info.get("package_xml_name", "package.xml")
156166
additional_folder = pkg_info.get("additional_folder", "")
157167
if additional_folder != "":
158168
additional_folder = additional_folder + "/"
159-
raw_url = f"https://raw.githubusercontent.com/{owner_repo}/{tag}/{additional_folder}{xml_name}"
169+
raw_url = f"https://raw.githubusercontent.com/{owner_repo}/{ref}/{additional_folder}{xml_name}"
160170
try:
161171
with urllib.request.urlopen(raw_url) as resp:
162172
return resp.read().decode('utf-8')

vinca/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,10 +641,10 @@ def generate_source(distro, vinca_conf):
641641
# skip cloning source for dummy recipes
642642
if is_dummy_metapackage(pkg_shortname, vinca_conf):
643643
continue
644-
url, version = distro.get_released_repo(pkg_shortname)
644+
url, ref, ref_type = distro.get_released_repo(pkg_shortname)
645645
entry = {}
646646
entry["git"] = url
647-
entry["tag"] = version
647+
entry[ref_type] = ref
648648
pkg_names = resolve_pkgname(pkg_shortname, vinca_conf, distro)
649649
pkg_version = distro.get_version(pkg_shortname)
650650
print("Checking ", pkg_shortname, pkg_version)
@@ -695,11 +695,11 @@ def generate_source_version(distro, vinca_conf):
695695
print(f"Could not generate source for {pkg_shortname}")
696696
continue
697697

698-
url, version = distro.get_released_repo(pkg_shortname)
698+
url, ref, ref_type = distro.get_released_repo(pkg_shortname)
699699

700700
entry = {}
701701
entry["git"] = url
702-
entry["tag"] = version
702+
entry[ref_type] = ref
703703
pkg_names = resolve_pkgname(pkg_shortname, vinca_conf, distro)
704704
if vinca_conf.get("trigger_new_versions"):
705705
if (
@@ -736,10 +736,10 @@ def generate_fat_source(distro, vinca_conf):
736736
print(f"Could not generate source for {pkg_shortname}")
737737
continue
738738

739-
url, version = distro.get_released_repo(pkg_shortname)
739+
url, ref, ref_type = distro.get_released_repo(pkg_shortname)
740740
entry = {}
741741
entry["git"] = url
742-
entry["tag"] = version
742+
entry[ref_type] = ref
743743
pkg_names = resolve_pkgname(pkg_shortname, vinca_conf, distro)
744744
if not pkg_names:
745745
continue

0 commit comments

Comments
 (0)