-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Rotendahl/test-action
Make option for excluding directories
- Loading branch information
Showing
5 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Test this action | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
name: Test action | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- run: | | ||
sh test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
echo "searching for CRLF endings in: $1" | ||
#!/bin/bash | ||
|
||
printf "searching for CRLF endings in: $1\n" | ||
# TODO allow multiple paths with $@ instead of $1 | ||
|
||
BOLD_RED='\033[1;31m' | ||
BOLD_GREEN='\033[1;32m' | ||
NC='\033[0m' | ||
|
||
ERROR_COUNT=0 | ||
FILES_TYPES="$(\ | ||
find . ! -path "./.git/*" -not -type d -exec file "{}" ";" | ||
)" | ||
|
||
if \ | ||
grep \ | ||
--recursive \ | ||
--files-with-matches \ | ||
--binary \ | ||
--binary-files=without-match \ | ||
--max-count=1 \ | ||
--exclude-dir="\.git" \ | ||
$'\r' \ | ||
$1 \ | ||
; then | ||
# TODO exit status should be number of files with wrong endings found | ||
echo -e "${BOLD_RED}Found at least a file with CRLF endings.${NC}" | ||
exit 1 | ||
fi | ||
FILES_WITH_CRLF=$(echo "$FILES_TYPES" | grep " CRLF " | cut -d " " -f 1 | cut -d ":" -f 1) | ||
|
||
echo -e "${BOLD_GREEN}No files with CRLF endings found.${NC}" | ||
exit 0 | ||
for word in $2 | ||
do | ||
FILES_WITH_CRLF=$(echo "$FILES_WITH_CRLF" | grep "^./$word" --invert-match) | ||
done | ||
|
||
if [ -z "$FILES_WITH_CRLF" ] | ||
then | ||
echo "${BOLD_GREEN}No files with CRLF endings found.${NC}" | ||
exit 0 | ||
else | ||
NR_FILES=$(echo "$FILES_WITH_CRLF" | wc -l) | ||
echo "${BOLD_RED}Found $NR_FILES files with CRLF endings.${NC}" | ||
echo "$FILES_WITH_CRLF" | ||
exit $NR_FILES | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# this is a sorry excuse for a test, but hey, it kinda works | ||
|
||
mkdir -p "temp" | ||
|
||
printf "\r\n" > "temp/bad" | ||
printf "\r\n" > "temp/ignored" | ||
printf "\n" > "temp/good" | ||
|
||
./entrypoint.sh . "temp/ignored" | ||
|
||
RESULT="$?" | ||
|
||
rm -r "temp" | ||
|
||
# is there a better way to do this? | ||
[ $RESULT -eq 1 ] | ||
exit $? |