fix(polecat): code review fixes

- Use errors.Is() instead of direct error comparison
- Add warning output when listing polecats fails for a rig
- Remove extra blank line

🤖 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-17 14:59:04 -08:00
parent fb4c71692a
commit 542bc32b00

View File

@@ -2,6 +2,7 @@ package cmd
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@@ -165,7 +166,6 @@ func getPolecatManager(rigName string) (*polecat.Manager, *rig.Rig, error) {
return mgr, r, nil return mgr, r, nil
} }
func runPolecatList(cmd *cobra.Command, args []string) error { func runPolecatList(cmd *cobra.Command, args []string) error {
var rigs []*rig.Rig var rigs []*rig.Rig
@@ -199,6 +199,7 @@ func runPolecatList(cmd *cobra.Command, args []string) error {
polecats, err := mgr.List() polecats, err := mgr.List()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "warning: failed to list polecats in %s: %v\n", r.Name, err)
continue continue
} }
@@ -303,7 +304,7 @@ func runPolecatRemove(cmd *cobra.Command, args []string) error {
fmt.Printf("Removing polecat %s/%s...\n", rigName, polecatName) fmt.Printf("Removing polecat %s/%s...\n", rigName, polecatName)
if err := mgr.Remove(polecatName); err != nil { if err := mgr.Remove(polecatName); err != nil {
if err == polecat.ErrHasChanges && !polecatForce { if errors.Is(err, polecat.ErrHasChanges) && !polecatForce {
return fmt.Errorf("polecat has uncommitted changes. Use --force to remove anyway") return fmt.Errorf("polecat has uncommitted changes. Use --force to remove anyway")
} }
return fmt.Errorf("removing polecat: %w", err) return fmt.Errorf("removing polecat: %w", err)