From 5549f554fe4781f0e997347c7460d721f8393455 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sun, 19 Nov 2023 20:37:42 +0700 Subject: [PATCH 1/2] fetchTree/fetchGit: add test for .gitattributes ...with the intention to prevent future regressions in fetchGit --- tests/functional/fetchGit.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/functional/fetchGit.sh b/tests/functional/fetchGit.sh index 4985c7764f6..f0438f548c0 100644 --- a/tests/functional/fetchGit.sh +++ b/tests/functional/fetchGit.sh @@ -229,6 +229,15 @@ rev_tag2=$(git -C $repo rev-parse refs/tags/tag2) [[ $rev_tag2_nix = $rev_tag2 ]] unset _NIX_FORCE_HTTP +# Ensure .gitattributes is respected +touch $repo/not-exported-file +echo "/not-exported-file export-ignore" >> $repo/.gitattributes +git -C $repo add not-exported-file .gitattributes +git -C $repo commit -m 'Bla6' +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 ]] + # should fail if there is no repo rm -rf $repo/.git (! nix eval --impure --raw --expr "(builtins.fetchGit \"file://$repo\").outPath") From eec2312b4f6c83de008a36317802bd49dbdcc83c Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 30 Dec 2023 17:04:27 +0700 Subject: [PATCH 2/2] fetchGit: add test for export-subst --- tests/functional/fetchGit.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/functional/fetchGit.sh b/tests/functional/fetchGit.sh index f0438f548c0..6390d67fdcb 100644 --- a/tests/functional/fetchGit.sh +++ b/tests/functional/fetchGit.sh @@ -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 @@ -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")