feat(context): centralize RepoContext API for git operations (#1102)

Centralizes repository context resolution via RepoContext API, fixing bugs where git commands run in the wrong repo when BEADS_DIR points elsewhere or in worktree scenarios.
This commit is contained in:
Peter Chanthamynavong
2026-01-15 07:55:08 -08:00
committed by GitHub
parent 159114563b
commit 0a48519561
33 changed files with 3211 additions and 327 deletions

View File

@@ -6,6 +6,9 @@ import (
"os/exec"
"path/filepath"
"testing"
"github.com/steveyegge/beads/internal/beads"
"github.com/steveyegge/beads/internal/git"
)
func TestMigrateSyncValidation(t *testing.T) {
@@ -96,6 +99,13 @@ func TestMigrateSyncDryRun(t *testing.T) {
// Note: We need to run this from tmpDir context since branchExistsLocal uses git in cwd
ctx := context.Background()
t.Chdir(tmpDir)
// Reset caches so RepoContext picks up new CWD
beads.ResetCaches()
git.ResetCaches()
defer func() {
beads.ResetCaches()
git.ResetCaches()
}()
if branchExistsLocal(ctx, "beads-sync") {
t.Error("branchExistsLocal should return false for non-existent branch")