fix: code review fixes from gt-2tp and gt-y0t

- Replace custom contains() with strings.Contains in init.go
- Make session stop --force flag actually work
- Update session.Manager.Stop() to accept force parameter

🤖 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-16 13:56:32 -08:00
parent eef28f3ee5
commit 29e4436891
5 changed files with 32 additions and 35 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/spf13/cobra"
"github.com/steveyegge/gastown/internal/git"
@@ -106,8 +107,7 @@ func updateGitExclude(repoPath string) error {
}
// Check if already has Gas Town section
contentStr := string(content)
if len(content) > 0 && contains(contentStr, "Gas Town") {
if strings.Contains(string(content), "Gas Town") {
return nil // Already configured
}
@@ -126,16 +126,3 @@ func updateGitExclude(repoPath string) error {
// Write back
return os.WriteFile(excludePath, append(content, []byte(additions)...), 0644)
}
func contains(s, substr string) bool {
return len(s) >= len(substr) && (s == substr || len(s) > 0 && containsHelper(s, substr))
}
func containsHelper(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {
if s[i:i+len(substr)] == substr {
return true
}
}
return false
}

View File

@@ -225,8 +225,12 @@ func runSessionStop(cmd *cobra.Command, args []string) error {
return err
}
fmt.Printf("Stopping session for %s/%s...\n", rigName, polecatName)
if err := mgr.Stop(polecatName); err != nil {
if sessionForce {
fmt.Printf("Force stopping session for %s/%s...\n", rigName, polecatName)
} else {
fmt.Printf("Stopping session for %s/%s...\n", rigName, polecatName)
}
if err := mgr.Stop(polecatName, sessionForce); err != nil {
return fmt.Errorf("stopping session: %w", err)
}