@@ -77,8 +77,8 @@ Available checks:
7777* ` imperative ` - First word is an imperative verb (for example ` add ` not ` added ` )
7878* ` body ` - Blank line separates subject from body, and body is non-empty
7979* ` signed-off ` - ` Signed-off-by: ` trailer exists
80- * ` signature ` - Verify GPG or SSH signature via GitHub public key lookup, with
81- fallback to ` git verify-commit `
80+ * ` signature ` - Verify GPG or SSH signature via the GitHub Commits API or
81+ public key lookup
8282
8383### Subject length
8484
@@ -202,20 +202,27 @@ independently of `--enable`/`--disable`.
202202
203203### Signature verification
204204
205- The ` signature ` check tries to verify the commit without any local keyring setup:
205+ The ` signature ` check verifies the commit without any local keyring setup:
206206
207- 1 . Look up the commit author's email in the GitHub API to find their GitHub
208- username.
209- 2 . Fetch their public keys from ` github.com/{username}.gpg ` and
207+ 1 . If the repo has a GitHub remote, call the Commits API
208+ (` GET /repos/{owner}/{repo}/commits/{sha} ` ) to resolve the author's GitHub
209+ username — this works for corporate emails, noreply addresses, or any email
210+ not listed publicly on a GitHub profile.
211+ 2 . If the Commits API is unavailable (no GitHub remote, commit not yet pushed,
212+ or API error), fall back to searching GitHub by the commit author's email.
213+ 3 . Fetch the resolved user's public keys from ` github.com/{username}.gpg ` and
210214 ` github.com/{username}.keys ` .
211- 3 . Try GPG verification: import the fetched key into a temporary keyring and
215+ 4 . Try GPG verification: import the fetched key into a temporary keyring and
212216 run ` git verify-commit ` .
213- 4 . Try SSH verification: write a temporary ` allowed_signers ` file and run
217+ 5 . Try SSH verification: write a temporary ` allowed_signers ` file and run
214218 ` git verify-commit ` with the SSH allowed-signers config.
215- 5 . If any key verifies, the check passes. If none do, it fails.
219+ 6 . If any key verifies, the check passes. If none do, it fails.
216220
217- If the author's email is not found on GitHub, or the API is unreachable, the
218- check fails with a clear error — there is no silent fallback.
221+ If the author cannot be resolved via either method, or the GitHub API is
222+ unreachable, the check fails with a clear error.
223+
224+ For private repositories, set ` GITHUB_TOKEN ` or ` GH_TOKEN ` so the Commits API
225+ can authenticate.
219226
220227### Configuration file
221228
@@ -251,9 +258,11 @@ full precedence and ignore config file values when provided.
251258
252259### Environment variables
253260
254- | Variable | Default | Description |
255- | -------------------------- | ------- | -------------------------------------------- |
256- | ` COMMIT_GUARD_GIT_TIMEOUT ` | ` 10 ` | Timeout in seconds for git subprocess calls. |
261+ | Variable | Default | Description |
262+ | -------------------------- | ------- | ------------------------------------------------------------------------- |
263+ | ` COMMIT_GUARD_GIT_TIMEOUT ` | ` 10 ` | Timeout in seconds for git subprocess calls. |
264+ | ` GITHUB_TOKEN ` | — | GitHub token for Commits API access on private repos (signature check). |
265+ | ` GH_TOKEN ` | — | Alias for ` GITHUB_TOKEN ` ; used when ` GITHUB_TOKEN ` is not set. |
257266
258267``` bash
259268COMMIT_GUARD_GIT_TIMEOUT=30 commit-guard --range origin/main..HEAD
0 commit comments