File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,13 +46,21 @@ jobs:
4646 exit 1
4747 fi
4848
49- - name : Print Modified Files
49+ - name : Check for Missing Final Newlines
5050 run : |
51- FILES=$(git ls-files --modified)
52- if [[ ! -z "$FILES" ]]; then
53- echo "The following files have incorrect trailing newlines:"
54- echo "$FILES"
55- echo "Please fix them using:"
56- echo -e 'if [[ -f "$1" ]]; then\n echo -n "$1"\n if (diff /dev/null "$1" || true) | tail -1 | grep -q "^\\ No newline"; then\n echo >> "$1"\n echo "...fixed"\n else\n echo ""\n fi\nfi'
57- false
51+ MISSING=""
52+ while IFS= read -r file; do
53+ if [[ -s "$file" && -n "$(tail -c1 "$file")" ]]; then
54+ MISSING="${MISSING}${file}"$'\n'
55+ fi
56+ done < <(git grep -Il '.' -- \
57+ ':(exclude)*.nix' \
58+ ':(exclude)*.sql' \
59+ ':(exclude)*.out' \
60+ ':(exclude)*.rs' \
61+ ':(exclude)docker/manifests/**')
62+ if [[ -n "$MISSING" ]]; then
63+ echo "The following files are missing a trailing newline:"
64+ echo "$MISSING"
65+ exit 1
5866 fi
You can’t perform that action at this time.
0 commit comments