feat: add Git worktree compatibility (PR #478)
Adds comprehensive Git worktree support for beads issue tracking: Core changes: - New internal/git/gitdir.go package for worktree detection - GetGitDir() returns proper .git location (main repo, not worktree) - Updated all hooks to use git.GetGitDir() instead of local helper - BeadsDir() now prioritizes main repository's .beads directory Features: - Hooks auto-install in main repo when run from worktree - Shared .beads directory across all worktrees - Config option no-install-hooks to disable auto-install - New bd worktree subcommand for diagnostics Documentation: - New docs/WORKTREES.md with setup instructions - Updated CHANGELOG.md and AGENT_INSTRUCTIONS.md Testing: - Updated tests to use exported git.GetGitDir() - Added worktree detection tests Co-authored-by: Claude <noreply@anthropic.com> Closes: #478
This commit is contained in:
@@ -148,7 +148,12 @@ func runMigrateSync(ctx context.Context, branchName string, dryRun, force bool)
|
||||
fmt.Printf("→ Would create new branch '%s'\n", branchName)
|
||||
}
|
||||
|
||||
worktreePath := filepath.Join(repoRoot, ".git", "beads-worktrees", branchName)
|
||||
// Use worktree-aware git directory detection
|
||||
gitDir, err := git.GetGitDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("not a git repository: %w", err)
|
||||
}
|
||||
worktreePath := filepath.Join(gitDir, "beads-worktrees", branchName)
|
||||
fmt.Printf("→ Would create worktree at: %s\n", worktreePath)
|
||||
|
||||
fmt.Println("\n=== END DRY RUN ===")
|
||||
@@ -183,7 +188,12 @@ func runMigrateSync(ctx context.Context, branchName string, dryRun, force bool)
|
||||
}
|
||||
|
||||
// Step 2: Create the worktree
|
||||
worktreePath := filepath.Join(repoRoot, ".git", "beads-worktrees", branchName)
|
||||
// Use worktree-aware git directory detection
|
||||
gitDir, err := git.GetGitDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("not a git repository: %w", err)
|
||||
}
|
||||
worktreePath := filepath.Join(gitDir, "beads-worktrees", branchName)
|
||||
fmt.Printf("→ Creating worktree at %s...\n", worktreePath)
|
||||
|
||||
wtMgr := git.NewWorktreeManager(repoRoot)
|
||||
|
||||
Reference in New Issue
Block a user