mirror of
https://github.com/wentasah/ros2nix.git
synced 2025-06-09 15:52:23 +03:00
feat: use sparse checkout if --use-package-git-hash is provided
This commit is contained in:
parent
72a061c8c1
commit
2b569c35f0
1 changed files with 8 additions and 8 deletions
|
@ -417,11 +417,8 @@ def ros2nix(args):
|
||||||
merge_base = merge_base_to_upstream(head)
|
merge_base = merge_base_to_upstream(head)
|
||||||
head = check_output(f"git rev-list {merge_base} -1 -- .".split())
|
head = check_output(f"git rev-list {merge_base} -1 -- .".split())
|
||||||
|
|
||||||
key = toplevel
|
if not args.use_package_git_hash and toplevel in git_cache: #only use cache if not using seperate checkout per package
|
||||||
if args.use_package_git_hash:
|
info = git_cache[toplevel]
|
||||||
key= f"{toplevel}/{head}"
|
|
||||||
if key in git_cache:
|
|
||||||
info = git_cache[key]
|
|
||||||
upstream_rev = info["rev"]
|
upstream_rev = info["rev"]
|
||||||
else:
|
else:
|
||||||
# Latest commit present in the upstream repo. If
|
# Latest commit present in the upstream repo. If
|
||||||
|
@ -431,12 +428,13 @@ def ros2nix(args):
|
||||||
upstream_rev = merge_base_to_upstream(head)
|
upstream_rev = merge_base_to_upstream(head)
|
||||||
info = json.loads(
|
info = json.loads(
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
["nix-prefetch-git", "--quiet", toplevel, upstream_rev],
|
["nix-prefetch-git", "--quiet"]+ (["--sparse-checkout", prefix] if (prefix and args.use_package_git_hash) else [])+[ toplevel, upstream_rev],
|
||||||
).decode()
|
).decode()
|
||||||
)
|
)
|
||||||
git_cache[key] = info
|
git_cache[toplevel] = info
|
||||||
|
|
||||||
match = re.match("https://github.com/(?P<owner>[^/]*)/(?P<repo>.*?)(.git|/.*)?$", url)
|
match = re.match("https://github.com/(?P<owner>[^/]*)/(?P<repo>.*?)(.git|/.*)?$", url)
|
||||||
|
sparse_checkout = f"sparseCheckout = [\"{prefix}\"];" if (prefix and args.use_package_git_hash) else ""
|
||||||
if match is not None:
|
if match is not None:
|
||||||
kwargs["src_param"] = "fetchFromGitHub"
|
kwargs["src_param"] = "fetchFromGitHub"
|
||||||
kwargs["src_expr"] = dedent(f'''
|
kwargs["src_expr"] = dedent(f'''
|
||||||
|
@ -445,6 +443,7 @@ def ros2nix(args):
|
||||||
repo = "{match["repo"]}";
|
repo = "{match["repo"]}";
|
||||||
rev = "{info["rev"]}";
|
rev = "{info["rev"]}";
|
||||||
sha256 = "{info["sha256"]}";
|
sha256 = "{info["sha256"]}";
|
||||||
|
{sparse_checkout}
|
||||||
}}''').strip()
|
}}''').strip()
|
||||||
else:
|
else:
|
||||||
kwargs["src_param"] = "fetchgit"
|
kwargs["src_param"] = "fetchgit"
|
||||||
|
@ -453,6 +452,7 @@ def ros2nix(args):
|
||||||
url = "{url}";
|
url = "{url}";
|
||||||
rev = "{info["rev"]}";
|
rev = "{info["rev"]}";
|
||||||
sha256 = "{info["sha256"]}";
|
sha256 = "{info["sha256"]}";
|
||||||
|
{sparse_checkout}
|
||||||
}}''').strip()
|
}}''').strip()
|
||||||
|
|
||||||
if prefix:
|
if prefix:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue