Conversation
`git ls-remote <remote> <ref>` matches the pattern against the tail of every ref name, so `#main` also lists `refs/heads/feature/main`, and `#v1` also lists `refs/heads/release/v1`. Those sort first, and resolveGitRef took the sha of the first line, so compose loaded the compose file from the wrong branch. Pick the ls-remote line whose ref name matches exactly, in git's own lookup order (as given, refs/, refs/tags/, refs/heads/). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: breken-ai <312387581+breken-ai@users.noreply.github.com>
This branch has not been deployed
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.
What I did
A git remote compose file could be loaded from the wrong branch or tag.
resolveGitRef(pkg/remote/git.go) runsgit ls-remote --exit-code <remote> <ref>and takes the sha from the first 40 bytes of the output. Butls-remotematches its pattern against the tail of every ref name, and prints the matches in ref order:So
...#mainresolves tofeature/mainwhenever such a branch exists. In the same way,#v1resolves to arelease/v1branch instead of thev1tag.The fix reads every line of the
ls-remoteoutput and picks the ref whose name matches exactly. It checks names in git's own lookup order: the ref as given, thenrefs/<ref>,refs/tags/<ref>andrefs/heads/<ref>.End to end, with a local
git daemonserving a repo whosecompose.yamlusesimage: from-mainonmainandimage: from-feature-mainonfeature/main:Tests:
TestResolveGitRefPicksExactRefbuilds a real local repo withmain,feature/main, av1tag and arelease/v1branch, then resolvesmain,refs/heads/mainandv1. Onmain,mainandv1resolve to the wrong sha. They pass here.TestMatchLsRemoteRefcovers the lookup order (a tag wins over a branch with the same name, as in git) and the error for a ref with no match.go test ./pkg/remote/passes.golangci-lint run --build-tags e2e ./pkg/remote/...(v2.13.2): 0 issues.This PR includes
AI_AGENT_DISCLOSURE.mdasAGENTS.mdasks. The ai-disclosure gate blocks merge until a human reviews the change and removes the file.Related issue
No existing issue or PR found.
(not mandatory) A picture of a cute animal, if possible in relation to what you did
🐿️ (fetched the right branch this time)
🤖 Generated with Claude Code