Browse Source

ci/workflows: Check PRs for trailing whitespace

Reject trailing whitespace, including in new files and lines.

Trailing spaces and tabs provide no value, can cause
inconsistent rendering, complicate diffs and merges, and
create needless whitespace-only changes in future edits.
Keeping them out makes source files cleaner and reviews
easier.

Use .gitattributes to limit checks to text files.
Fetch full history to make the PR base and head commits available.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 1 month ago
parent
commit
4d5069e474
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 14
      .github/workflows/git-attributes.yml

14
.github/workflows/git-attributes.yml

@ -9,6 +9,8 @@ jobs: @@ -9,6 +9,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for line ending violations
run: |
@ -27,3 +29,15 @@ jobs: @@ -27,3 +29,15 @@ jobs:
fi
echo "All files have correct line endings."
- name: Check for trailing whitespace
run: |
if ! git diff --check \
"${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" \
-- ':(attr:text)' ':(attr:text=auto)'; then
echo "::error::Trailing whitespace found in the pull request."
echo "Remove trailing spaces and tabs from added lines."
exit 1
fi
echo "No trailing whitespace found in the pull request."

Loading…
Cancel
Save