fix(spawn): resolve variable shadowing and branch deletion edge case
- Move router and polecatAddress definitions before if block to avoid shadowing (defining same vars inside and after the block) - Handle branch deletion failure in Recreate() by checking if branch still exists and using WorktreeAddExisting like Add() does 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,9 @@ func runSpawn(cmd *cobra.Command, args []string) error {
|
||||
polecatGit := git.NewGit(r.Path)
|
||||
polecatMgr := polecat.NewManager(r, polecatGit)
|
||||
|
||||
// Router for mail operations (used for checking inbox and sending assignments)
|
||||
router := mail.NewRouter(r.Path)
|
||||
|
||||
// Auto-select polecat if not specified
|
||||
if polecatName == "" {
|
||||
polecatName, err = selectIdlePolecat(polecatMgr, r)
|
||||
@@ -160,6 +163,9 @@ func runSpawn(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Address for this polecat (used for mail operations)
|
||||
polecatAddress := fmt.Sprintf("%s/%s", rigName, polecatName)
|
||||
|
||||
// Check if polecat exists
|
||||
existingPolecat, err := polecatMgr.Get(polecatName)
|
||||
polecatExists := err == nil
|
||||
@@ -196,8 +202,6 @@ func runSpawn(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
// Check for unread mail (indicates existing unstarted work)
|
||||
polecatAddress := fmt.Sprintf("%s/%s", rigName, polecatName)
|
||||
router := mail.NewRouter(r.Path)
|
||||
mailbox, mailErr := router.GetMailbox(polecatAddress)
|
||||
if mailErr == nil {
|
||||
_, unread, _ := mailbox.Count()
|
||||
@@ -229,10 +233,6 @@ func runSpawn(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("getting polecat: %w", err)
|
||||
}
|
||||
|
||||
// Define polecatAddress and router for later use (mail sending)
|
||||
polecatAddress := fmt.Sprintf("%s/%s", rigName, polecatName)
|
||||
router := mail.NewRouter(r.Path)
|
||||
|
||||
// Beads operations use rig-level beads (at rig root, not mayor/rig)
|
||||
beadsPath := r.Path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user