Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/static-analysis-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,31 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Search for linter suppression markers
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.sha }}
run: |
export BASE_REF=${{ github.event.pull_request.base.ref }}
export CHANGED_FILES="$(git diff --name-only origin/$BASE_REF HEAD | grep '^tasks/')"
set -euo pipefail

CHANGED_FILES="$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" -- 'tasks/')"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix quoting in git diff range

The new CHANGED_FILES assignment escapes the quotes around HEAD_SHA (git diff --name-only "$BASE_SHA"...\"$HEAD_SHA\" -- 'tasks/'), which produces the literal range BASE..."<sha>". git diff treats that as an invalid revision and exits with fatal: bad revision, and with set -euo pipefail the nolint-check step will now fail before scanning files on every PR. The range should not include escaped quotes around HEAD_SHA.

Useful? React with 👍 / 👎.


if [ -z "$CHANGED_FILES" ]; then
echo "No changed files in tasks directory."
exit 0
fi

for file in $CHANGED_FILES; do
if grep -n "NOLINT" "$file"; then
if grep -q "NOLINT" "$file"; then
echo "::error::Found 'NOLINT' in $file."
exit 1
fi
if grep -En 'IWYU[[:space:]]+pragma' "$file"; then
if grep -Eq 'IWYU[[:space:]]+pragma' "$file"; then
echo "::error::Found 'IWYU pragma' in $file."
exit 1
fi
done

echo "No linter suppression markers found in changed files."
Loading