Repository navigation
[worker:coverage] test(checkouts): add behavioral tests for Manager::checkout_of - #302
Conversation
Add three tests that exercise the main paths of Manager::checkout_of using a local bare-clone as the remote, so no network is required: - checkout_of_new_remote_returns_valid_path_and_rev: verifies that a first-time checkout returns an existing directory with the committed file present and the correct rev SHA. - checkout_of_same_branch_twice_uses_cache: verifies that a second call for the same GitRef::Branch returns the cached path and rev without creating a new worktree. - checkout_of_commit_ref_reuses_branch_worktree: verifies that requesting a commit hash matching an existing branch checkout reuses the same directory rather than allocating a new worktree. Also fix run_git_bare to set GIT_DIR explicitly so git recognises the bare repository as intentional when safe.bareRepository=explicit is configured (the default since git 2.49). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR adds comprehensive test coverage for the ChangesCheckout manager test coverage and git bare repo compatibility
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
Adds three behavioral tests for
Manager::checkout_ofusing a local bare-clone as the remote, so no network is required:checkout_of_new_remote_returns_valid_path_and_rev— a first-time checkout of an unseen remote returns a directory that exists, contains the committed file, and reports the correct rev SHA.checkout_of_same_branch_twice_uses_cache— a second call for the sameGitRef::Branchreturns the cached path and rev without creating a new worktree (exercises theSome(id)early-return branch).checkout_of_commit_ref_reuses_branch_worktree— requesting a commit hash that matches an existing branch checkout reuses the same directory rather than allocating a new worktree (exercises theGitRef::Commitfast-path).Also fixes
run_git_bareto set theGIT_DIRenvironment variable explicitly, so git recognises the bare repository as intentional whensafe.bareRepository = explicitis in effect (the default since git 2.49). Without this fix the worktree-add commands fail in any environment with the 2.49 default, making the production tool non-functional on modern git.Verification
cargo fmt --all --check— no diff.cargo clippy --workspace --all-targets—Finished 'dev' profile ... in 9m 13s(0 warnings, exit 0).cargo test --workspace --all-targets— all tests passed (exit 0).Closes #299
Summary by CodeRabbit
Bug Fixes
Tests