fix: report why a git command failed, and stop blaming an unpushed branch for it ai:gpt-5.6-sol #83
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/gogogo!83
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ls-remote-error-reporting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two defects found while diagnosing a
gogogo packfailure in another repository. The run aborted with:Neither half of that message was usable. The branch was pushed, and the actual cause was a transient transport failure — which the message managed to both hide and misattribute. Diagnosis cost a repository audit (gitignore rules, symlinks, payload selection) before it became clear that nothing had been packed at all: the run died in the pre-flight check.
1.
exit status 128hid git's explanationCmd.Output()captures standard error intoexec.ExitError.Stderr, butexec.ExitError.Error()prints only the status, so the reason was dropped on the way to the operator. Exit 128 is git's generic fatal — it cannot distinguish an unreachable host from a bad URL, stale credentials, or a server outage.Cmd.Outputnow returns the previously unusedinternal/exec.ExitErrorwrapper, whoseError()appends the captured text. Fixing it at that one point rather than at the call site covers all ten sites ininternal/gitalone, plus every otherOutput()caller, with no call-site churn.Unwrapkeepserrors.As/errors.Isworking for callers that inspect the exit status.Before and after, same repository, same broken remote:
Three details worth reviewing:
internal/buildmoves tointernal/execasRedactCredentials, so there is one implementation instead of two rather than a parallel abstraction.exit status 1, with no dangling colon.2. The hint blamed the branch for a network problem
checkRepoStatefails for two unrelated reasons — the remote answered and does not carry HEAD, or the remote could not be queried at all — and both got "push your branch, …". For a transport failure that is wrong: the branch may already be pushed, and pushing cannot fix DNS, credentials or an outage. It is what sent me looking at branch state and then at packaging for a network fault.The unpushed case becomes the sentinel
ErrHeadNotOnRemote;repoHintselects from it:Both keep the
--ignore-remote/--no-networkescape hatches, which apply either way.internal/cmd/releasealready separates these two cases (release.go:304vs:309); onlydoctorconflated them.Tests
Regression tests at each layer, all hermetic — no network, no live remote:
internal/exec: stderr reaches the message,errors.Asstill finds theexec.ExitErrorand its exit code, silent failures stay unchanged, credentials are redacted, floods are truncated, and the detail survives thefmt.Errorf("…: %w")wrapping every caller applies.internal/git:RemoteContainsCommitagainst a non-repository path reports git's explanation, not just a status.internal/cmd/doctor: hint selection for both causes, including a wrapped sentinel.Verification
go build ./...,go test ./...,go vet ./...all pass.golangci-lint run --new-from-rev origin/masterreports 0 issues; the 18wsl_v5findings on a full run are pre-existing onmasterand untouched. Both commits build and test standing alone.Behaviour verified end-to-end by rebuilding the binary and reproducing the original failure, both for an unreachable remote and for a genuinely unpushed branch.
(authored by ai:gpt-5.6-sol)
c66d446b7dtod90671185a