From 0b9bd900215c914f60eb4bd51a472915209b4c52 Mon Sep 17 00:00:00 2001 From: Pascal THUET Date: Thu, 21 May 2026 03:57:00 +0200 Subject: [PATCH] ci: add diff whitespace check (#2572) --- .github/workflows/lint.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c2606d698..873abc642 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,28 @@ jobs: steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 1 + + - name: Run git diff --check + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + PUSH_BEFORE_SHA: ${{ github.event.before }} + GITHUB_SHA: ${{ github.sha }} + run: | + set -euo pipefail + + if [ "$EVENT_NAME" = "pull_request" ]; then + git fetch --no-tags --depth=1 origin "+${PR_BASE_SHA}:refs/checks/pr-base" + git diff --check refs/checks/pr-base HEAD + elif [ "$PUSH_BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then + git diff-tree --check --no-commit-id --root -r "$GITHUB_SHA" + else + git fetch --no-tags --depth=1 origin "+${PUSH_BEFORE_SHA}:refs/checks/push-before" + git diff --check refs/checks/push-before HEAD + fi - name: Run markdownlint-cli2 uses: DavidAnson/markdownlint-cli2-action@ded1f9488f68a970bc66ea5619e13e9b52e601cd # v23