Fix bundle() missing git_checkout for non-default branch names#233
Closed
mari0d wants to merge 2 commits into
Closed
Fix bundle() missing git_checkout for non-default branch names#233mari0d wants to merge 2 commits into
mari0d wants to merge 2 commits into
Conversation
When bundling packages via --manifest with a fresh clone (package not already installed), bundle() called git_clone() but never called git_checkout() afterwards. This caused the bundled working tree to always reflect the remote default branch HEAD, regardless of the version specified in the manifest. All other code paths (_info(), test(), _install()) correctly call git_checkout() after cloning. The fix captures the git.Repo return value from git_clone() and calls git_checkout() when version is a non-SHA1 ref (branch name or tag). SHA1 versions are unaffected: the correct version is checked out at unbundle/install time via _install() which has access to the full git history (shallow=False for SHA1s). Adds a regression test that bundles a package pinned to a non-default branch via --manifest and verifies the bundle archive contains the correct working tree content.
Add cat manifest.ini and tar -tzf steps to surface the actual bundle contents in the btest diag on CI failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Fixes #232.
Problem
bundle()callsgit_clone()but never callsgit_checkout()afterwards — the return value ofgit_clone()is discarded. When bundling via--manifestwith a non-default branch name, the clone lands on the remote's default branch HEAD and that is what gets archived into the bundle, not the requested branch.Every other code path in the manager (
_info(),test(),_install()) correctly callsgit_checkout()after cloning.bundle()was the only exception.Fix
Capture the
git.Reporeturn value fromgit_clone()and callgit_checkout(clone, version)whenversionis a non-empty, non-SHA1 ref (branch name or tag).SHA1 versions are intentionally excluded: they use a full clone (
shallow=False) so the correct commit is reachable, andunbundle()→_install()already callsgit_checkout()at install time with full history available.Test
Added
testing/tests/bundle-non-default-branchwhich:feature-branchthat has distinct content frommain--manifest(fresh-clone path,prefer_existing_clones=False)zkg unbundle, which masks the bug by callinggit_checkoutitself) and verifies the working tree contains the feature branch contentAI Disclosure
This fix was developed with assistance from Claude Code (Anthropic Claude Sonnet 4.6). The bug was identified, the fix was written, and the regression test was authored with AI assistance. I reviewed, understood, and validated all changes before submission.