Skip to content
Open
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
20 changes: 12 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ jobs:
files: coverage.out

commit-lint:
# On pull_request: lint the PR title (which becomes the merge commit
# subject on squash-merge). On push/merge_group: lint each commit.
# Lint the PR title and individual commits on pull_request.
# Lint each commit on push/merge_group.
# The merge queue uses merge (not squash), so individual commit
# messages matter — catch bad prefixes before the merge queue rejects them.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand All @@ -72,19 +74,21 @@ jobs:
uvx --from gitlint-core gitlint --config .gitlint --ignore B6 --msg-filename /tmp/pr-title.txt

- name: Lint commits
if: github.event_name != 'pull_request'
env:
EVENT_NAME: ${{ github.event_name }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_AFTER: ${{ github.sha }}
MQ_BASE: ${{ github.event.merge_group.base_sha }}
MQ_HEAD: ${{ github.event.merge_group.head_sha }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] edge-case

The pull_request range uses github.event.pull_request.base.sha..github.event.pull_request.head.sha. The base SHA is the tip of the target branch at event time, not the merge-base. If main has diverged significantly from the PR fork point, git rev-list --no-merges could include commits the author did not write, leading to spurious lint failures. Unlikely in practice with typical PR workflows.

run: |
if [ "${EVENT_NAME}" = "push" ]; then
RANGE="${PUSH_BEFORE}..${PUSH_AFTER}"
else
RANGE="${MQ_BASE}..${MQ_HEAD}"
fi
case "${EVENT_NAME}" in
push) RANGE="${PUSH_BEFORE}..${PUSH_AFTER}" ;;
merge_group) RANGE="${MQ_BASE}..${MQ_HEAD}" ;;
pull_request) RANGE="${PR_BASE}..${PR_HEAD}" ;;
*) echo "Unknown event: ${EVENT_NAME}"; exit 1 ;;
esac

FAILED=false
for sha in $(git rev-list --no-merges "${RANGE}"); do
Expand Down
Loading