Skip to content

Commit

Permalink
fetchGit: add test for export-subst
Browse files Browse the repository at this point in the history
  • Loading branch information
DavHau committed Dec 30, 2023
1 parent 5549f55 commit eec2312
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/functional/fetchGit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ rev_tag2=$(git -C $repo rev-parse refs/tags/tag2)
[[ $rev_tag2_nix = $rev_tag2 ]]
unset _NIX_FORCE_HTTP

# Ensure .gitattributes is respected
# Ensure export-ignore in .gitattributes is respected
touch $repo/not-exported-file
echo "/not-exported-file export-ignore" >> $repo/.gitattributes
git -C $repo add not-exported-file .gitattributes
Expand All @@ -238,6 +238,16 @@ rev5=$(git -C $repo rev-parse HEAD)
path12=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev5\"; }).outPath")
[[ ! -e $path12/not-exported-file ]]

# Ensure export-subst in .gitattributes is respected
echo '$Format:%H$' > $repo/exported-file
echo '/exported-file export-subst' >> $repo/.gitattributes
git -C $repo add exported-file .gitattributes
git -C $repo commit -m 'Bla7'
rev6=$(git -C $repo rev-parse HEAD)
path13=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$repo; rev = \"$rev6\"; }).outPath")
[[ $(cat $path13/exported-file) = $rev6 ]]
[[ $(cat $path13/exported-file) != '$Format:%H$' ]]

# should fail if there is no repo
rm -rf $repo/.git
(! nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath")
Expand Down

0 comments on commit eec2312

Please sign in to comment.