Use "non-cone mode" for --use-per-package-src

In cone mode (before this commit), the fetched sources contained not
only the specified subdirectory, but also the files in all its parent
directories. Non-cone mode means, that only the specified subdirectory
is fetched.
This commit is contained in:
Michal Sojka 2025-02-09 10:46:55 +01:00
parent 3567e9e85a
commit 5053709228

View file

@ -430,7 +430,7 @@ def ros2nix(args):
subprocess.check_output(
["nix-prefetch-git", "--quiet"]
+ (
["--sparse-checkout", prefix]
["--sparse-checkout", prefix, "--non-cone-mode"]
if prefix and args.use_per_package_src
else []
)
@ -440,7 +440,9 @@ def ros2nix(args):
git_cache[toplevel] = info
match = re.match("https://github.com/(?P<owner>[^/]*)/(?P<repo>.*?)(.git|/.*)?$", url)
sparse_checkout = f"sparseCheckout = [\"{prefix}\"];" if (prefix and args.use_per_package_src) else ""
sparse_checkout = f"""sparseCheckout = ["{prefix}"];
nonConeMode = true;""" if prefix and args.use_per_package_src else ""
if match is not None:
kwargs["src_param"] = "fetchFromGitHub"
kwargs["src_expr"] = strip_empty_lines(dedent(f'''