Fix "nothing to commit" error with LF/CRLF changes #241 (#265)

* fix crlf test

* add diff check before commit

* add dirty check flag (not sure if needed)

* Update test name and add more assertions

Update test name to make it clear that the Action no longer fails to detect CRLF changes.

* Add Comment to explain why we use git-diff again

* Add test to confirm content changes are commited

* Closes #241 

Co-authored-by: Stefan Zweifel <hello@stefanzweifel.io>
This commit is contained in:
ZeroRin
2022-12-02 03:47:06 +08:00
committed by GitHub
parent 976f22029f
commit 3ea6ae190b
2 changed files with 68 additions and 12 deletions

View File

@@ -25,11 +25,28 @@ _main() {
_add_files
_local_commit
# Check dirty state of repo again using git-diff.
# (git-diff detects beter if CRLF of files changes and does NOT
# proceed, if only CRLF changes are detected. See #241 and #265
# for more details.)
if [ -n "$(git diff --staged)" ] || "$INPUT_SKIP_DIRTY_CHECK"; then
_local_commit
_tag_commit
_tag_commit
_push_to_github
_push_to_github
else
# Check if $GITHUB_OUTPUT is available
# (Feature detection will be removed in late December 2022)
if [ -z ${GITHUB_OUTPUT+x} ]; then
echo "::set-output name=changes_detected::false";
else
echo "changes_detected=false" >> $GITHUB_OUTPUT;
fi
echo "Working tree clean. Nothing to commit.";
fi
else
# Check if $GITHUB_OUTPUT is available