feat: Implement bare repo architecture for branch visibility (gt-gmqe)

- Add .repo.git as shared bare repo for worktrees
- Update polecat manager to use bare repo when available
- Add git.NewGitWithDir() and CloneBare() for bare repo support
- Update gt rig init to create bare repo architecture for new rigs
- Refinery and polecats now share branch visibility via shared .git

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-25 18:49:34 -08:00
parent 200b2065a6
commit 1b66b9a2f2
4 changed files with 100 additions and 36 deletions

View File

@@ -20,6 +20,7 @@ var (
// Git wraps git operations for a working directory.
type Git struct {
workDir string
gitDir string // Optional: explicit git directory (for bare repos)
}
// NewGit creates a new Git wrapper for the given directory.
@@ -27,6 +28,13 @@ func NewGit(workDir string) *Git {
return &Git{workDir: workDir}
}
// NewGitWithDir creates a Git wrapper with an explicit git directory.
// This is used for bare repos where gitDir points to the .git directory
// and workDir may be empty or point to a worktree.
func NewGitWithDir(gitDir, workDir string) *Git {
return &Git{gitDir: gitDir, workDir: workDir}
}
// WorkDir returns the working directory for this Git instance.
func (g *Git) WorkDir() string {
return g.workDir
@@ -34,8 +42,15 @@ func (g *Git) WorkDir() string {
// run executes a git command and returns stdout.
func (g *Git) run(args ...string) (string, error) {
// If gitDir is set (bare repo), prepend --git-dir flag
if g.gitDir != "" {
args = append([]string{"--git-dir=" + g.gitDir}, args...)
}
cmd := exec.Command("git", args...)
cmd.Dir = g.workDir
if g.workDir != "" {
cmd.Dir = g.workDir
}
var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
@@ -84,6 +99,18 @@ func (g *Git) Clone(url, dest string) error {
return nil
}
// CloneBare clones a repository as a bare repo (no working directory).
// This is used for the shared repo architecture where all worktrees share a single git database.
func (g *Git) CloneBare(url, dest string) error {
cmd := exec.Command("git", "clone", "--bare", url, dest)
var stderr bytes.Buffer
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return g.wrapError(err, stderr.String(), []string{"clone", "--bare", url})
}
return nil
}
// Checkout checks out the given ref.
func (g *Git) Checkout(ref string) error {
_, err := g.run("checkout", ref)