fix(spawn): reset stale polecat branches to origin/main
When recreating a polecat worktree, the branch deletion might fail silently, leaving a stale branch with old commits. The worktree would then be created from this stale branch, missing recent main changes. Fix: - Add ResetBranch() method to git package for force-updating branches - Fetch from origin before recreation to ensure fresh commits - If branch deletion fails, force-reset the branch to origin/main - This ensures polecats always start with the latest code Discovered during gt-8tmz swarm when nux polecat was missing the internal/formula/ directory that was added after its branch diverged. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -401,6 +401,13 @@ func (g *Git) DeleteBranch(name string, force bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ResetBranch force-updates a branch to point to a ref.
|
||||
// This is useful for resetting stale polecat branches to main.
|
||||
func (g *Git) ResetBranch(name, ref string) error {
|
||||
_, err := g.run("branch", "-f", name, ref)
|
||||
return err
|
||||
}
|
||||
|
||||
// Rev returns the commit hash for the given ref.
|
||||
func (g *Git) Rev(ref string) (string, error) {
|
||||
return g.run("rev-parse", ref)
|
||||
|
||||
Reference in New Issue
Block a user