From dcbc52dc5972241ccedca50564921e69b22c68a7 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 30 Nov 2022 21:02:33 +0100 Subject: [PATCH] Add test to confirm content changes are commited --- tests/git-auto-commit.bats | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats index 3d903b4..ead4db7 100644 --- a/tests/git-auto-commit.bats +++ b/tests/git-auto-commit.bats @@ -1009,6 +1009,40 @@ cat_github_output() { assert_line "changes_detected=false" } +@test "detects if crlf in files change and creates commit if the actual content of the files change" { + # Set autocrlf to true + cd "${FAKE_LOCAL_REPOSITORY}" + git config core.autocrlf true + run git config --get-all core.autocrlf + assert_line "true" + + # Add more .txt files + echo -ne "crlf test1\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt + echo -ne "crlf test1\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt + + # Run git-auto-commit to add new files to repository + run git_auto_commit + + # Change control characters in files + echo -ne "crlf test2\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt + echo -ne "crlf test2\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt + + # Run git-auto-commit to commit the 2 changes files + run git_auto_commit + + assert_success + + assert_line --partial "2 files changed, 2 insertions(+), 2 deletions(-)" + assert_line --partial "warning: in the working copy of 'new-file-2.txt', LF will be replaced by CRLF the next time Git touches it" + + assert_line --partial "new-file-2.txt" + assert_line --partial "new-file-3.txt" + + # Changes are detected + run cat_github_output + assert_line "changes_detected=true" +} + @test "It uses old set-output syntax if GITHUB_OUTPUT environment is not available when changes are committed" { unset GITHUB_OUTPUT