File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,25 +34,23 @@ jobs:
3434
3535 - name : Check for Trailing Whitespaces
3636 run : |
37- FILES=$(git grep -Ilr '[[:blank:]]$' -- \
38- ':(exclude)*.nix' \
39- ':(exclude)*.sql' \
40- ':(exclude)*.out' \
41- ':(exclude)*.rs' \
42- ':(exclude)docker/manifests/**' || true)
37+ FILES=$(git grep -Ilr '[[:blank:]]$' || true)
4338 if [[ ! -z "$FILES" ]]; then
4439 echo "The following files have trailing whitespaces:"
4540 echo "$FILES"
4641 exit 1
4742 fi
4843
49- - name : Print Modified Files
44+ - name : Check for Missing Final Newlines
5045 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
46+ MISSING=""
47+ while IFS= read -r file; do
48+ if [[ -s "$file" && -n "$(tail -c1 "$file")" ]]; then
49+ MISSING="${MISSING}${file}"$'\n'
50+ fi
51+ done < <(git grep -Il '.')
52+ if [[ -n "$MISSING" ]]; then
53+ echo "The following files are missing a trailing newline:"
54+ echo "$MISSING"
55+ exit 1
5856 fi
You can’t perform that action at this time.
0 commit comments