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:
matt wilkie
2025-12-13 10:40:40 -08:00
committed by Steve Yegge
parent de7b511765
commit e01b7412d9
64 changed files with 1895 additions and 3708 deletions

View File

@@ -51,11 +51,10 @@ jobs:
file: ./coverage.out
fail_ci_if_error: false
# Windows smoke tests only - full test suite times out (see bd-bmev)
# Linux runs comprehensive tests; Windows just verifies binary works
test-windows:
name: Test (Windows - smoke)
test-windows-cmd:
name: Test (Windows - cmd)
runs-on: windows-latest
continue-on-error: true # Windows filesystem is slow; don't block PRs
steps:
- uses: actions/checkout@v6
@@ -70,22 +69,30 @@ jobs:
git config --global user.email "ci@beads.test"
- name: Build
run: go build -v -o bd.exe ./cmd/bd
run: go build -v ./cmd/bd
- name: Smoke test - version
run: ./bd.exe version
- name: Test cmd package
run: go test -v -short -timeout=30m -parallel=4 ./cmd/...
- name: Smoke test - init and CRUD
test-windows-internal:
name: Test (Windows - internal)
runs-on: windows-latest
continue-on-error: true # Windows filesystem is slow; don't block PRs
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Configure Git
run: |
./bd.exe init --quiet --prefix smoke
$output = ./bd.exe create --title "Windows smoke test" --type task
$id = ($output | Select-String -Pattern "smoke-\w+").Matches.Value
echo "Created issue: $id"
./bd.exe list
./bd.exe show $id
./bd.exe update $id --status in_progress
./bd.exe close $id
echo "All smoke tests passed!"
git config --global user.name "CI Bot"
git config --global user.email "ci@beads.test"
- name: Test internal packages
run: go test -v -short -timeout=30m -parallel=4 ./internal/...
lint:
name: Lint
@@ -129,13 +136,3 @@ jobs:
exit 1
fi
echo "✅ Help text first line is correct"
- name: Verify default.nix package version matches bd program version
run: |
BD_VERSION=$(grep 'Version = ' cmd/bd/version.go | sed 's/.*"\(.*\)".*/\1/')
NIX_BD_VERSION=$(grep 'version = ' default.nix | sed 's/.*"\(.*\)".*/\1/')
if [ "$BD_VERSION" != "$NIX_BD_VERSION" ]; then
echo "❌ default.nix version ($NIX_BD_VERSION) != version.go ($BD_VERSION)"
echo "Run: scripts/bump-version.sh to sync default.nix"
exit 1
fi
echo "✅ default.nix version matches: $BD_VERSION"

View File

@@ -80,7 +80,7 @@ jobs:
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'