fix(formula): set rigPath when falling back to gastown default
When `gt formula run` fell back to the default "gastown" rig (because no rig could be detected), it didn't set rigPath, which meant the default formula lookup would fail. Now rigPath is properly constructed when we have townRoot but can't detect a current rig. Also adds tests for GetDefaultFormula helper. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
6016f15da9
commit
afb944f616
@@ -212,9 +212,14 @@ func runFormulaRun(cmd *cobra.Command, args []string) error {
|
||||
rigPath = r.Path
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we still don't have a target rig but have townRoot, use gastown
|
||||
if targetRig == "" {
|
||||
targetRig = "gastown" // Default
|
||||
targetRig = "gastown"
|
||||
rigPath = filepath.Join(townRoot, "gastown")
|
||||
}
|
||||
} else {
|
||||
// No town root found, fall back to gastown without rigPath
|
||||
targetRig = "gastown"
|
||||
}
|
||||
} else {
|
||||
// If rig specified, construct path
|
||||
|
||||
@@ -1577,6 +1577,44 @@ func TestSaveTownSettings(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetDefaultFormula(t *testing.T) {
|
||||
t.Run("returns empty string for nonexistent rig", func(t *testing.T) {
|
||||
result := GetDefaultFormula("/nonexistent/path")
|
||||
if result != "" {
|
||||
t.Errorf("GetDefaultFormula() = %q, want empty string", result)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("returns empty string when no workflow config", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
settings := NewRigSettings()
|
||||
if err := SaveRigSettings(RigSettingsPath(dir), settings); err != nil {
|
||||
t.Fatalf("SaveRigSettings: %v", err)
|
||||
}
|
||||
|
||||
result := GetDefaultFormula(dir)
|
||||
if result != "" {
|
||||
t.Errorf("GetDefaultFormula() = %q, want empty string", result)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("returns default formula when configured", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
settings := NewRigSettings()
|
||||
settings.Workflow = &WorkflowConfig{
|
||||
DefaultFormula: "shiny",
|
||||
}
|
||||
if err := SaveRigSettings(RigSettingsPath(dir), settings); err != nil {
|
||||
t.Fatalf("SaveRigSettings: %v", err)
|
||||
}
|
||||
|
||||
result := GetDefaultFormula(dir)
|
||||
if result != "shiny" {
|
||||
t.Errorf("GetDefaultFormula() = %q, want %q", result, "shiny")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// TestLookupAgentConfigWithRigSettings verifies that lookupAgentConfig checks
|
||||
// rig-level agents first, then town-level agents, then built-ins.
|
||||
func TestLookupAgentConfigWithRigSettings(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user