This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch juerg/translate-url in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git
commit ce1624975749e5c760fe8a733911d2f4779e4c80 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Apr 5 11:32:42 2024 +0200 cargo: Improve backward compatibility Append a trailing slash to the specified URL if necessary, without breaking cache keys. --- src/buildstream_plugins/sources/cargo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/buildstream_plugins/sources/cargo.py b/src/buildstream_plugins/sources/cargo.py index 709399f..e30cd06 100644 --- a/src/buildstream_plugins/sources/cargo.py +++ b/src/buildstream_plugins/sources/cargo.py @@ -308,10 +308,17 @@ class CargoSource(Source): # The url before any aliasing # - self.url = node.get_str("url", "https://static.crates.io/crates/") + self.original_url = node.get_str("url", "https://static.crates.io/crates") self.cargo_lock = node.get_str("cargo-lock", "Cargo.lock") self.vendor_dir = node.get_str("vendor-dir", "crates") + # If the specified URL is just an alias, require the alias to resolve + # to a URL with a trailing slash. Otherwise, append a trailing slash if + # it's missing, for backward compatibility. + self.url = self.original_url + if not self.url.endswith(":") and not self.url.endswith("/"): + self.url += "/" + node.validate_keys(Source.COMMON_CONFIG_KEYS + ["url", "ref", "cargo-lock", "vendor-dir"]) # Needs to be marked here so that `track` can translate it later. @@ -323,7 +330,7 @@ class CargoSource(Source): return def get_unique_key(self): - return [self.url, self.cargo_lock, self.vendor_dir, self.ref] + return [self.original_url, self.cargo_lock, self.vendor_dir, self.ref] def is_resolved(self): return (self.ref is not None) and all(crate.is_resolved() for crate in self.crates)
