From 368221b2858f705a833848df1d724193efa33ae1 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Thu, 23 Jul 2026 23:00:43 +1000 Subject: [PATCH] fix: pull latest instead of skipping when worktree exists --- internal/worktree/worktree.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/worktree/worktree.go b/internal/worktree/worktree.go index 0b4b2b101..96f9253a9 100644 --- a/internal/worktree/worktree.go +++ b/internal/worktree/worktree.go @@ -74,7 +74,16 @@ func (m *Manager) Prepare(ctx context.Context, owner, repo, base string, issue i branch = archieBranch(issue, title, body, labels) // Already prepared (daemon cloned before container acquire). + // Pull latest to avoid working on stale code. if st, statErr := os.Stat(filepath.Join(dir, ".git")); statErr == nil && st.IsDir() { + if _, err := m.git(ctx, dir, "fetch", "origin"); err != nil { + return "", "", err + } + if _, err := m.git(ctx, dir, "checkout", branch); err == nil { + if _, err := m.git(ctx, dir, "reset", "--hard", "origin/"+base); err != nil { + return "", "", err + } + } return dir, branch, nil } if err := os.RemoveAll(dir); err != nil {