mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Fix fetchGit nested submodules
This commit is contained in:
parent
e1fd0e0a8c
commit
750bcaa330
2 changed files with 47 additions and 0 deletions
|
@ -642,6 +642,8 @@ struct GitInputScheme : InputScheme
|
|||
attrs.insert_or_assign("ref", submodule.branch);
|
||||
attrs.insert_or_assign("rev", submoduleRev.gitRev());
|
||||
attrs.insert_or_assign("exportIgnore", Explicit<bool>{ exportIgnore });
|
||||
attrs.insert_or_assign("submodules", Explicit<bool>{ true });
|
||||
attrs.insert_or_assign("allRefs", Explicit<bool>{ true });
|
||||
auto submoduleInput = fetchers::Input::fromAttrs(std::move(attrs));
|
||||
auto [submoduleAccessor, submoduleInput2] =
|
||||
submoduleInput.getAccessor(store);
|
||||
|
@ -696,6 +698,9 @@ struct GitInputScheme : InputScheme
|
|||
attrs.insert_or_assign("type", "git");
|
||||
attrs.insert_or_assign("url", submodulePath.abs());
|
||||
attrs.insert_or_assign("exportIgnore", Explicit<bool>{ exportIgnore });
|
||||
attrs.insert_or_assign("submodules", Explicit<bool>{ true });
|
||||
// TODO: fall back to getAccessorFromCommit-like fetch when submodules aren't checked out
|
||||
// attrs.insert_or_assign("allRefs", Explicit<bool>{ true });
|
||||
|
||||
auto submoduleInput = fetchers::Input::fromAttrs(std::move(attrs));
|
||||
auto [submoduleAccessor, submoduleInput2] =
|
||||
|
|
|
@ -170,3 +170,45 @@ pathWithSubmodules=$(nix eval --impure --raw --expr "(builtins.fetchGit { url =
|
|||
|
||||
[[ -e $pathWithoutExportIgnore/exclude-from-root ]]
|
||||
[[ -e $pathWithoutExportIgnore/sub/exclude-from-sub ]]
|
||||
|
||||
test_submodule_nested() {
|
||||
local repoA=$TEST_ROOT/submodule_nested/a
|
||||
local repoB=$TEST_ROOT/submodule_nested/b
|
||||
local repoC=$TEST_ROOT/submodule_nested/c
|
||||
|
||||
rm -rf $repoA $repoB $repoC $TEST_HOME/.cache/nix
|
||||
|
||||
initGitRepo $repoC
|
||||
touch $repoC/inside-c
|
||||
git -C $repoC add inside-c
|
||||
addGitContent $repoC
|
||||
|
||||
initGitRepo $repoB
|
||||
git -C $repoB submodule add $repoC c
|
||||
git -C $repoB add c
|
||||
addGitContent $repoB
|
||||
|
||||
initGitRepo $repoA
|
||||
git -C $repoA submodule add $repoB b
|
||||
git -C $repoA add b
|
||||
addGitContent $repoA
|
||||
|
||||
|
||||
# Check non-worktree fetch
|
||||
local rev=$(git -C $repoA rev-parse HEAD)
|
||||
out=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repoA\"; rev = \"$rev\"; submodules = true; }).outPath")
|
||||
test -e $out/b/c/inside-c
|
||||
test -e $out/content
|
||||
test -e $out/b/content
|
||||
test -e $out/b/c/content
|
||||
local nonWorktree=$out
|
||||
|
||||
# Check worktree based fetch
|
||||
# TODO: make it work without git submodule update
|
||||
git -C $repoA submodule update --init --recursive
|
||||
out=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = \"file://$repoA\"; submodules = true; }).outPath")
|
||||
find $out
|
||||
[[ $out == $nonWorktree ]] || { find $out; false; }
|
||||
|
||||
}
|
||||
test_submodule_nested
|
||||
|
|
Loading…
Reference in a new issue