Skip to content

Commit

Permalink
Add more test for git submodule functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
blitz committed Mar 29, 2020
1 parent c8d33de commit c846abb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/fetchGitSubmodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,23 @@ rev=$(git -C $rootRepo rev-parse HEAD)

pathWithoutSubmodules=$(nix eval --raw "(builtins.fetchGit { url = file:https://$rootRepo; rev = \"$rev\"; }).outPath")
pathWithSubmodules=$(nix eval --raw "(builtins.fetchGit { url = file:https://$rootRepo; rev = \"$rev\"; fetchSubmodules = true; }).outPath")
pathWithSubmodulesAgain=$(nix eval --raw "(builtins.fetchGit { url = file:https://$rootRepo; rev = \"$rev\"; fetchSubmodules = true; }).outPath")

# The resulting store path cannot be the same.
[[ $pathWithoutSubmodules != $pathWithSubmodules ]]

# Checking out the same repo with submodules returns in the same store path.
[[ $pathWithSubmodules == $pathWithSubmodulesAgain ]]

# The submodules flag is actually honored.
[[ ! -e $pathWithoutSubmodules/sub/content ]]
[[ -e $pathWithSubmodules/sub/content ]]

# No .git directory or submodule reference files must be left
test "$(find "$pathWithSubmodules" -name .git)" = ""

# Git repos without submodules can be fetched with submodules = true.
noSubmoduleRepoBaseline=$(nix eval --raw "(builtins.fetchGit { url = file:https://$subRepo; rev = \"$rev\"; }).outPath")
noSubmoduleRepo=$(nix eval --raw "(builtins.fetchGit { url = file:https://$subRepo; rev = \"$rev\"; fetchSubmodules = true; }).outPath")

[[ $noSubmoduleRepoBaseline == $noSubmoduleRepo ]]

0 comments on commit c846abb

Please sign in to comment.