fix(rig): remove route from routes.jsonl on rig remove (#910)
When a rig is removed with `gt rig remove`, the route entry in routes.jsonl was not being cleaned up. This caused problems when re-adding the rig with a different prefix, resulting in duplicate entries and prefix mismatch errors. The fix calls beads.RemoveRoute() during rig removal to clean up the route entry from routes.jsonl. Fixes #899 Co-authored-by: dementus <julianknutsen@users.noreply.github> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -505,6 +505,12 @@ func runRigRemove(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("loading rigs config: %w", err)
|
||||
}
|
||||
|
||||
// Get the rig's beads prefix before removing (needed for route cleanup)
|
||||
var beadsPrefix string
|
||||
if entry, ok := rigsConfig.Rigs[name]; ok && entry.BeadsConfig != nil {
|
||||
beadsPrefix = entry.BeadsConfig.Prefix
|
||||
}
|
||||
|
||||
// Create rig manager
|
||||
g := git.NewGit(townRoot)
|
||||
mgr := rig.NewManager(townRoot, rigsConfig, g)
|
||||
@@ -518,6 +524,14 @@ func runRigRemove(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("saving rigs config: %w", err)
|
||||
}
|
||||
|
||||
// Remove route from routes.jsonl (issue #899)
|
||||
if beadsPrefix != "" {
|
||||
if err := beads.RemoveRoute(townRoot, beadsPrefix+"-"); err != nil {
|
||||
// Non-fatal: log warning but continue
|
||||
fmt.Printf(" %s Could not remove route from routes.jsonl: %v\n", style.Warning.Render("!"), err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("%s Rig %s removed from registry\n", style.Success.Render("✓"), name)
|
||||
fmt.Printf("\nNote: Files at %s were NOT deleted.\n", filepath.Join(townRoot, name))
|
||||
fmt.Printf("To delete: %s\n", style.Dim.Render(fmt.Sprintf("rm -rf %s", filepath.Join(townRoot, name))))
|
||||
|
||||
Reference in New Issue
Block a user