fix: ensure gitignore patterns on role creation

Add EnsureGitignorePatterns to rig package that ensures .gitignore
has required Gas Town patterns (.runtime/, .claude/, .beads/, .logs/).

Called from crew and polecat managers when creating new workers.
This prevents runtime-gitignore warnings from gt doctor.

The function:
- Creates .gitignore if it doesn't exist
- Appends missing patterns to existing files
- Recognizes pattern variants (.runtime vs .runtime/)
- Adds "# Gas Town" header when appending

Includes comprehensive tests for all scenarios.
This commit is contained in:
Dustin Smith
2026-01-18 17:08:19 +07:00
committed by Steve Yegge
parent 05ea767149
commit 2aadb0165b
4 changed files with 277 additions and 0 deletions
+10
View File
@@ -334,6 +334,11 @@ func (m *Manager) AddWithOptions(name string, opts AddOptions) (*Polecat, error)
fmt.Printf("Warning: could not copy overlay files: %v\n", err)
}
// Ensure .gitignore has required Gas Town patterns
if err := rig.EnsureGitignorePatterns(clonePath); err != nil {
fmt.Printf("Warning: could not update .gitignore: %v\n", err)
}
// Run setup hooks from .runtime/setup-hooks/.
// These hooks can inject local git config, copy secrets, or perform other setup tasks.
if err := rig.RunSetupHooks(m.rig.Path, clonePath); err != nil {
@@ -638,6 +643,11 @@ func (m *Manager) RepairWorktreeWithOptions(name string, force bool, opts AddOpt
fmt.Printf("Warning: could not copy overlay files: %v\n", err)
}
// Ensure .gitignore has required Gas Town patterns
if err := rig.EnsureGitignorePatterns(newClonePath); err != nil {
fmt.Printf("Warning: could not update .gitignore: %v\n", err)
}
// NOTE: Slash commands inherited from town level - no per-workspace copies needed.
// Create or reopen agent bead for ZFC compliance