fix: anchor clone-vs-proxy verification to the same commit #29
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
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
heiko/gogogo!29
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ai-claude-fix-proxy"
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?
Summary
Fixes a race condition in
executeFromClonewhere the Go module proxy could resolve a branch-name ref to a different commit than the one just cloned. This causedVerifyCloneto compare hashes that were never meant to match.v1.2.3) the tag name is still passed to the proxy directly — so the release gets the canonical version string.HEAD, and pseudo-versions the proxy is now queried with the commit SHA returned byCloneRepo, anchoring both sides to the same commit.Drive-bys:
CloneReponow returns the resolved HEAD SHA, removing a redundantgit.Openin the caller.VerifyCloneaccepts the already-fetched*ModDownloadInfoinstead of making a second proxy round-trip.Related
Test plan
go build ./...cleango test ./...all passgolangci-lint runno issues[AI-Generated Review]
I have reviewed Pull Request #29. Here is my evaluation of the changes.
Summary of Changes
The PR addresses a race condition that occurs during the clone verification phase (
VerifyClone). Previously, when a branch name (e.g.,main) was provided as the release target, the codebase would check out the branch locally but query the Go module proxy using that same branch name. If the proxy served a cached, older commit (or if a new commit was pushed to the branch in the exact moment between the git clone and the proxy query), the cloned hash and the proxy hash would mismatch, causing the build to fail unnecessarily.The Fix:
CloneRepowas modified to return the exact commit SHA of the checked-out clone.releasecommand logic was updated to use this concrete commit SHA when querying the module proxy, except when dealing with stable semantic version tags (which are immutable).VerifyCloneno longer makes a redundant network call toResolveModuleVersion. Instead, it now directly accepts the*ModDownloadInfothat the caller has already retrieved.ctxparameter inVerifyClonewas removed because it no longer performs network requests.Code Review
internal/builder/clone.go: The change toCloneReposignature correctly propagates the SHA string. The introduction ofreadCloneHeadprovides a clean way to fetch the SHA without relying on standard output parsing of a shell command, utilizing the internalgit.Openandrepo.HeadCommit()mechanisms.internal/builder/verify.go: The refactoring here is excellent. Passing*ModDownloadInfodirectly avoids the second HTTP round-trip to the module proxy, making the verification slightly faster and reducing external dependency risks.internal/cmd/release/release.go: The proxy ref determination is sound: This correctly separates branches/pseudo-versions (which need exact SHA anchoring) from stable semver tags likev1.0.0(which must be queried as-is so the proxy records and returns the canonical version name rather than a raw SHA).internal/builder/verify_test.go: The test was correctly updated to align with the newVerifyClonesignature.Testing
I have run the test suite locally against the PR commit, and all packages passed successfully without issue.
Conclusion
This PR correctly identifies and elegantly fixes an annoying race condition that affects non-tag-based builds. The optimization in
VerifyCloneis a great drive-by improvement.Status: Approved. The code is clean, idiomatic Go, and safe to merge.