polecat: fresh unique branches per run, add gc command (gt-ake0m)
Changed polecat branch model to use unique timestamped branches (polecat/<name>-<timestamp>) instead of reusing persistent branches. This prevents JSONL drift issues where stale polecat branches don't have recently created beads. Changes: - Add(): create unique branch, simplified (no reuse logic) - Recreate(): create fresh branch, old ones left for GC - loadFromBeads(): read actual branch from git worktree - CleanupStaleBranches(): remove orphaned polecat branches - ListBranches(pattern): new git helper for branch enumeration - gt polecat gc: new command to clean up stale branches 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -401,6 +401,24 @@ func (g *Git) DeleteBranch(name string, force bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ListBranches returns all local branches matching a pattern.
|
||||
// Pattern uses git's pattern matching (e.g., "polecat/*" matches all polecat branches).
|
||||
// Returns branch names without the refs/heads/ prefix.
|
||||
func (g *Git) ListBranches(pattern string) ([]string, error) {
|
||||
args := []string{"branch", "--list", "--format=%(refname:short)"}
|
||||
if pattern != "" {
|
||||
args = append(args, pattern)
|
||||
}
|
||||
out, err := g.run(args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if out == "" {
|
||||
return nil, nil
|
||||
}
|
||||
return strings.Split(out, "\n"), nil
|
||||
}
|
||||
|
||||
// ResetBranch force-updates a branch to point to a ref.
|
||||
// This is useful for resetting stale polecat branches to main.
|
||||
func (g *Git) ResetBranch(name, ref string) error {
|
||||
|
||||
Reference in New Issue
Block a user