From 168e805d0ccce8cfae393d0b2f6532584ad59ad4 Mon Sep 17 00:00:00 2001 From: chrome Date: Mon, 5 Jan 2026 00:18:01 -0800 Subject: [PATCH] fix: log rig discovery errors instead of silently swallowing (gt-rsnj9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DiscoverRigs() now logs failed rig loads to stderr instead of silently continuing - AddRig warnings now output to stderr instead of stdout, matching the codebase convention for non-fatal warnings - Added clarifying comment for best-effort git ref update in worktree 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/git/git.go | 3 ++- internal/rig/manager.go | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/git/git.go b/internal/git/git.go index eeb097f1..97a9dd51 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -853,7 +853,8 @@ func (g *Git) BranchPushedToRemote(localBranch, remote string) (bool, int, error // See: gt-cehl8 (gt done fails in worktrees due to missing origin tracking ref) remoteRef := "refs/remotes/" + remoteBranch if _, err := g.run("rev-parse", "--verify", remoteRef); err != nil { - // Remote ref doesn't exist locally - update it from FETCH_HEAD if fetch succeeded + // Remote ref doesn't exist locally - update it from FETCH_HEAD if fetch succeeded. + // Best-effort: if this fails, the code below falls back to ls-remote. if fetchErr == nil { _, _ = g.run("update-ref", remoteRef, "FETCH_HEAD") } diff --git a/internal/rig/manager.go b/internal/rig/manager.go index 5c7a0ab1..02be1056 100644 --- a/internal/rig/manager.go +++ b/internal/rig/manager.go @@ -62,13 +62,14 @@ func NewManager(townRoot string, rigsConfig *config.RigsConfig, g *git.Git) *Man } // DiscoverRigs returns all rigs registered in the workspace. +// Rigs that fail to load are logged to stderr and skipped; partial results are returned. func (m *Manager) DiscoverRigs() ([]*Rig, error) { var rigs []*Rig for name, entry := range m.config.Rigs { rig, err := m.loadRig(name, entry) if err != nil { - // Log error but continue with other rigs + fmt.Fprintf(os.Stderr, "Warning: failed to load rig %q: %v\n", name, err) continue } rigs = append(rigs, rig) @@ -443,19 +444,19 @@ Use crew for your own workspace. Polecats are for batch work dispatch. // Town-level agents (mayor, deacon) are created by gt install in town beads. if err := m.initAgentBeads(rigPath, opts.Name, opts.BeadsPrefix); err != nil { // Non-fatal: log warning but continue - fmt.Printf(" Warning: Could not create agent beads: %v\n", err) + fmt.Fprintf(os.Stderr, " Warning: Could not create agent beads: %v\n", err) } // Seed patrol molecules for this rig if err := m.seedPatrolMolecules(rigPath); err != nil { // Non-fatal: log warning but continue - fmt.Printf(" Warning: Could not seed patrol molecules: %v\n", err) + fmt.Fprintf(os.Stderr, " Warning: Could not seed patrol molecules: %v\n", err) } // Create plugin directories if err := m.createPluginDirectories(rigPath); err != nil { // Non-fatal: log warning but continue - fmt.Printf(" Warning: Could not create plugin directories: %v\n", err) + fmt.Fprintf(os.Stderr, " Warning: Could not create plugin directories: %v\n", err) } // Register in town config