Skip to content

ci(commitlint): skip pull requests that carry no commits - #517

Merged
gitfromwildan merged 1 commit into
mainfrom
ci/commitlint-skip-empty-range
Nov 10, 2026
Merged

gitfromwildan merged 1 commit into
mainfrom
ci/commitlint-skip-empty-range

Conversation

@gitfromwildan

Copy link
Copy Markdown
Member

Summary

The Commitlint check failed on #513 (run) without any bad commit message.

Cause

Renovate reset renovate/vite-8.x-lockfile to a main that already had vite 8.3.6 from #514, so the pull request's base and head were the same commit (34d6568). commitlint rejects that range:

Invalid input flags: --from and --to point to the same commit.
::error::commitlint exited with 9 and reported no results

GitHub then marked #513 as merged with zero commits, so that PR needs no further action.

Fix

The "Lint commits" step counts the commits between base and head first (git rev-list --count). When there are none it ends with a ::notice:: instead of calling commitlint. Everything after that is unchanged.

Verification

The step's script, extracted from the workflow and run locally with the same env vars:

Case Result
Empty range (34d6568..34d6568, the #513 shape), new step passes with "No commits between base and head" notice
Three valid commits (c888ac8..34d6568) passes, 0 problems
One commit with a message that has no type fails, 2 problems
Empty range, old step fails with exit 9, same as CI

When Renovate resets a branch to a main that already has its update, the
pull request's base and head point to the same commit. commitlint 21
rejects that range with exit code 9 ("--from and --to point to the same
commit"), and the step reported it as a failure (seen on #513). Count the
commits between base and head first and skip linting with a notice when
there are none.
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docu Ignored Ignored Nov 10, 2026 3:07am UTC

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Reviewed the one change to the Commitlint workflow (mode: standard). It stops commitlint from failing on pull requests whose base and head are the same commit.

  • Skip empty commit ranges — the "Lint commits" step now runs git rev-list --count "$BASE_SHA..$HEAD_SHA" first. When the result is 0, it emits a ::notice:: and exits 0 instead of calling commitlint, which exits 9 on that input.

Overall assessment: ready to merge. I checked these edge cases and found nothing to fix:

  • actions/checkout uses fetch-depth: 0, so both SHAs are available to rev-list.
  • If rev-list ever errored, [ "" -eq 0 ] would evaluate to false inside the if, so it does not trigger bash -e. The step would then fall through to commitlint, so it can never pass silently.
  • A head that is behind base also counts 0 and is skipped. That is correct, because the PR has no commits of its own.
  • The existing reported no commits to check branch can still be reached, for example when the PR contains only merge commits, which commitlint ignores by default. Keeping it is right.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@gitfromwildan
gitfromwildan merged commit 5c6e927 into main Nov 10, 2026
15 checks passed
@gitfromwildan
gitfromwildan deleted the ci/commitlint-skip-empty-range branch November 10, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant