## What
`hack/check-commit-trailers.sh` printed `Commit trailers OK: 0 commit(s)
checked.` and exited 0 when the range it was given resolved to zero
commits, so a run that examined nothing was indistinguishable from a
clean run. An empty range now prints a message naming the empty case and
exits 1.
## Why
The documented pre-push recipe in `docs/agents/contributing.md` is
`hack/check-commit-trailers.sh origin/main..HEAD`. The range is resolved
in the process working directory, so an agent whose shell sits in a
different checkout than the branch resolves it against the wrong `HEAD`
and gets nothing — and the old green there was a green nobody could tell
from a real one, defeating the check precisely when the checkout is
misconfigured. The CI path is unaffected:
`.github/workflows/pre-commit.yml` builds the range from a pull
request's merge base and head SHA, which GitHub refuses to open with no
commits between the two, and which goes empty only once the base has
absorbed the head's commits and there is nothing left to merge, where a
red trailer check is harmless.
## Test
TDD, bats: the previously buggy `accepts an empty range` test is
inverted into `fails on an empty range instead of reporting OK`, which
asserts a non-zero exit, that the message names the empty case, and that
the `Commit trailers OK` line is absent. Mutation-verified — removing
the guard turns it RED, restoring it turns it GREEN. Full suite: 28
passing, 0 failing.
## Release note
```release-note
Local runs of `hack/check-commit-trailers.sh` now fail on an empty commit range instead of reporting OK, so the documented pre-push check no longer passes silently when it examined nothing.
```
Fixes#4263
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Bug Fixes**
- Commit trailer checks now fail when the specified commit range
contains no commits.
- Empty ranges no longer report a misleading successful validation.
- Error output clearly indicates that no commits were checked.
- **Tests**
- Added coverage confirming empty commit ranges return a failure status
and appropriate diagnostic output.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->