fix: Polecat lifecycle cleanup - stale worktrees and git tracking
Fixes gt-v07fl: Polecat lifecycle cleanup for stale worktrees and git tracking conflicts. Changes: 1. Add .claude/ to .gitignore (prevents untracked file accumulation) 2. Add beads runtime state patterns to .gitignore (prevents future tracking) 3. Remove .beads/ runtime state from git tracking (mq/, issues.jsonl, etc.) - Formulas and config remain tracked (needed for go install) - Created follow-up gt-mpyuq for formulas refactor 4. Add DetectStalePolecats() to polecat manager for identifying cleanup candidates 5. Add CountCommitsBehind() to git package for staleness detection 6. Add `gt polecat stale <rig>` command for stale polecat detection/cleanup - Shows polecats without active sessions - Identifies polecats far behind main (configurable threshold) - Optional --cleanup flag to auto-nuke stale polecats The existing `gt polecat gc` command handles branch cleanup. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -699,6 +699,24 @@ func (g *Git) CommitsAhead(base, branch string) (int, error) {
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// CountCommitsBehind returns the number of commits that HEAD is behind the given ref.
|
||||
// For example, CountCommitsBehind("origin/main") returns how many commits
|
||||
// are on origin/main that are not on the current HEAD.
|
||||
func (g *Git) CountCommitsBehind(ref string) (int, error) {
|
||||
out, err := g.run("rev-list", "--count", "HEAD.."+ref)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var count int
|
||||
_, err = fmt.Sscanf(out, "%d", &count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("parsing commit count: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// StashCount returns the number of stashes in the repository.
|
||||
func (g *Git) StashCount() (int, error) {
|
||||
out, err := g.run("stash", "list")
|
||||
|
||||
Reference in New Issue
Block a user