From 4d5069e4742d790df0b2caa365fb84961825bd7e Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sun, 11 Oct 2026 16:02:20 -0400 Subject: [PATCH] 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 --- .github/workflows/git-attributes.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/git-attributes.yml b/.github/workflows/git-attributes.yml index 7637713bd..60eb352b2 100644 --- a/.github/workflows/git-attributes.yml +++ b/.github/workflows/git-attributes.yml @@ -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: 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."