Skip to content

Commit 6678e98

Browse files
authored
Merge pull request #4922 from nrdxp/default-submodules
libfetchers/git: fetch submodules by default
2 parents 90b2dd5 + 769ca4e commit 6678e98

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/libexpr/primops/fetchTree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void emitTreeAttrs(
4545

4646
if (input.getType() == "git")
4747
mkBool(*state.allocAttr(v, state.symbols.create("submodules")),
48-
fetchers::maybeGetBoolAttr(input.attrs, "submodules").value_or(false));
48+
fetchers::maybeGetBoolAttr(input.attrs, "submodules").value_or(true));
4949

5050
if (auto revCount = input.getRevCount())
5151
mkInt(*state.allocAttr(v, state.symbols.create("revCount")), *revCount);

src/libfetchers/git.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct GitInputScheme : InputScheme
173173
std::string name = input.getName();
174174

175175
bool shallow = maybeGetBoolAttr(input.attrs, "shallow").value_or(false);
176-
bool submodules = maybeGetBoolAttr(input.attrs, "submodules").value_or(false);
176+
bool submodules = maybeGetBoolAttr(input.attrs, "submodules").value_or(true);
177177
bool allRefs = maybeGetBoolAttr(input.attrs, "allRefs").value_or(false);
178178

179179
std::string cacheType = "git";

tests/fetchGitSubmodules.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ r1=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \
4242
r2=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = false; }).outPath")
4343
r3=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
4444

45-
[[ $r1 == $r2 ]]
46-
[[ $r2 != $r3 ]]
45+
[[ $r1 == $r3 ]]
46+
[[ $r2 != $r1 ]]
4747

4848
r4=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; }).outPath")
4949
r5=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = false; }).outPath")
@@ -52,22 +52,22 @@ r7=$(nix eval --raw --expr "(builtins.fetchGit { url = $rootRepo; ref = \"master
5252
r8=$(nix eval --raw --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
5353

5454
[[ $r1 == $r4 ]]
55-
[[ $r4 == $r5 ]]
55+
[[ $r4 == $r6 ]]
5656
[[ $r3 == $r6 ]]
5757
[[ $r6 == $r7 ]]
5858
[[ $r7 == $r8 ]]
5959

6060
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; }).submodules")
61-
[[ $have_submodules == false ]]
61+
[[ $have_submodules == true ]]
6262

6363
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = false; }).submodules")
6464
[[ $have_submodules == false ]]
6565

6666
have_submodules=$(nix eval --expr "(builtins.fetchGit { url = $rootRepo; rev = \"$rev\"; submodules = true; }).submodules")
6767
[[ $have_submodules == true ]]
6868

69-
pathWithoutSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; }).outPath")
70-
pathWithSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
69+
pathWithoutSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = false; }).outPath")
70+
pathWithSubmodules=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; }).outPath")
7171
pathWithSubmodulesAgain=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; rev = \"$rev\"; submodules = true; }).outPath")
7272
pathWithSubmodulesAgainWithRef=$(nix eval --raw --expr "(builtins.fetchGit { url = file://$rootRepo; ref = \"master\"; rev = \"$rev\"; submodules = true; }).outPath")
7373

0 commit comments

Comments
 (0)