Skip to content

fix(git): surface git log failures instead of swallowing them as empty range - #448

Merged
joshua-temple merged 1 commit into
mainfrom
fix/git-surface-errors-land
Jul 5, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
fix/git-surface-errors-land

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

git.GetCommits treated any git failure that produced empty stdout as an empty commit range and returned (nil, nil), swallowing the error. A genuinely empty range already exits 0, so that branch was reached only when git exited non-zero: a bad or unknown base SHA after a history rewrite, a shallow clone missing the base commit, or a non-repository path. The caller then saw zero commits, derived no version bump, and recomputed the same base version. The result was a silent wrong-version cut with no warning logged.

Fix

Distinguish exit status from empty output. Return the wrapped error when git exits non-zero, and keep the empty-range case (exit 0, no output) returning no commits and no error.

Verification

go build ./..., go test ./... -race -count=1, and golangci-lint run ./... all clean locally, including a new test that asserts a non-zero git exit surfaces an error rather than an empty slice.

…y range

GetCommits returned (nil, nil) whenever git exited non-zero with empty
stdout, treating a bad or unknown base SHA, a shallow clone missing the
base commit, or a non-repository as an empty commit range. Callers then
saw zero commits, computed no version bump, and cut the same version with
no warning. A legitimately empty range exits 0 and already returns no
commits via parseCommits, so any error from git log is a real failure and
is now returned.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit dd1a051 into main Jul 5, 2026
19 checks passed
@joshua-temple
joshua-temple deleted the fix/git-surface-errors-land branch July 5, 2026 01:06
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