Skip to content

Commit a649a53

Browse files
committed
Add test cases
1 parent 14a7b65 commit a649a53

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/functional/fetchGit.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,26 @@ git -C "$empty" config user.name "Foobar"
303303
git -C "$empty" commit --allow-empty --allow-empty-message --message ""
304304

305305
nix eval --impure --expr "let attrs = builtins.fetchGit $empty; in assert attrs.lastModified != 0; assert attrs.rev != \"0000000000000000000000000000000000000000\"; assert attrs.revCount == 1; true"
306+
307+
# Test a repo with `eol=crlf`.
308+
repo="$TEST_ROOT/crlf"
309+
git init "$repo"
310+
git -C $repo config user.email "foobar@example.com"
311+
git -C $repo config user.name "Foobar"
312+
313+
echo -n -e 'foo\nbar\nbaz' > "$repo/newlines.txt"
314+
echo -n -e 'foo\nbar\nbaz' > "$repo/test.txt"
315+
git -C "$repo" add newlines.txt test.txt
316+
git -C "$repo" commit -m 'Add files containing LF line endings'
317+
echo 'test.txt eol=crlf' > "$repo/.gitattributes"
318+
git -C "$repo" add .gitattributes
319+
git -C "$repo" commit -m 'Add eol=crlf to gitattributes'
320+
narhash=$(nix eval --raw --impure --expr "(builtins.fetchGit { url = \"$repo\"; ref = \"master\"; }).narHash")
321+
[[ "$narhash" = "sha256-k7u7RAaF+OvrbtT3KCCDQA8e9uOdflUo5zSgsosoLzA=" ]]
322+
323+
# Ensure that NAR hash doesn't depend on user configuration.
324+
rm -rf $TEST_HOME/.cache/nix
325+
export GIT_CONFIG_GLOBAL="$TEST_ROOT/gitconfig"
326+
git config --global core.autocrlf true
327+
new_narhash=$(nix eval --raw --impure --expr "(builtins.fetchGit { url = \"$repo\"; ref = \"master\"; }).narHash")
328+
[[ "$new_narhash" = "$narhash" ]]

0 commit comments

Comments
 (0)