mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
Merge pull request #10670 from NixOS/backport-10588-to-2.21-maintenance
[Backport 2.21-maintenance] Fix fetchGit/fetchTree for nested submodules
This commit is contained in:
commit
375acc48ea
@ -639,6 +639,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);
|
||||
@ -690,6 +692,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 New Issue
Block a user