Repository navigation
fix: lint push events using event payload commits instead of full history - #20
Merged
Merged
Conversation
…tory On push events in tagless repositories, semrel lint fell through to ListCommitsSinceTag(nil) which walked the entire commit history, failing on historical non-conventional commits. This affected every consumer repo that triggers lint on push events without any release tags (e.g. ps-terraform-config with 2927 commits / 1705 violations). Fix by reading the pushed commits directly from the GitHub event payload (GITHUB_EVENT_PATH) on push events. This validates exactly the commits included in the push, not the entire repository history. Fallback behaviour is preserved: when the event payload is unavailable or unreadable, semrel falls back to the previous tag-based range. Explicit --from-ref always overrides automatic detection. Changes: - env: add PushCommit type and loadPushPayload() to parse push event JSON - cli: route push-event lint through event payload commits - cli: add commitsFromPushPayload() helper - docs: update lint range documentation for push-event semantics
richardmoe
force-pushed
the
fix/push-lint-event-payload
branch
from
August 12, 2026 08:19
679b0fd to
d3d93d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On
pushevents in tagless repositories (likeps-terraform-config),semrel lintfell through toListCommitsSinceTag(nil)which walked the entire commit history. Inps-terraform-configthis meant linting all 2927 commits and finding 1705 violations in historical commits that predate conventional commit adoption.The recent fix in #17 (
2992c59) fixed thepull_requestpath to useGITHUB_BASE_REF→HEAD, but thepushpath was unchanged. Any consumer repo that:pushevents, ANDwould fail every push-event lint check.
Failing run: https://github.com/nrkno/ps-terraform-config/actions/runs/31571178223/job/94033318956?pr=1976
Root cause
On
push,fromRefresolved to empty (no tags), so lint fell through to the bootstrap path (ListCommitsSinceTag(nil)), linting the entire repository history.Fix
Read the pushed commits directly from the GitHub event payload (
GITHUB_EVENT_PATH) onpushevents. This validates exactly the commits included in the push, not the entire repository history.Fallback preserved: when the event payload is unavailable or unreadable, semrel falls back to the previous tag-based range. Explicit
--from-refalways overrides automatic detection.Changes
internal/env/env.goPushCommittype +loadPushPayload()— parses push event JSONinternal/cli/cli.gocommitsFromPushPayload()helperinternal/env/env_test.gointernal/cli/cli_test.go--from-refoverridesintegration_test.godocs/api-reference.mddocs/configuration.md--from-refandGITHUB_EVENT_NAMEdescriptionsdocs/log.mdCHANGELOG.mdVerification