fix(daemon): resume a retry whose worktree is gone

prepareWorkspace chose between Manager.Prepare (refresh onto base) and a
separate Manager.Resume, and Manager.Resume only opened an
already-prepared clone. A remediation whose local worktree the terminal
cleanup removed, an expired volume dropped, or a different host never had
could therefore never be resumed, and the retry path had no way to select
the mode that continues pushed work.

Unify the two matched methods into Prepare(..., Target): Fresh resets onto
origin/<base>, a non-empty Target resets onto origin/<that branch>, and
either target clones a missing worktree. The daemon's retry path selects
the target from the task row and passes the persisted branch, so a resume
lands on the branch the open PR lives on and fails closed when it is not
on the remote.

Delete the container-mode no-op resume (hybridTrees.Resume and the
resumableTrees capability) now that the daemon owns it. The remediate
workflow no longer stages a resume, and the retired remediate.resume step
word stays resolvable as an inert stage: a stored definition is validated
as a whole collection, so a removed word would fail every workflow to
decode, not just its own.
This commit is contained in:
sam committed 2026-10-02 10:24:52 +10:00
1 parent c70b144782
commit 6ff239ee70
22 files changed
+363 -246

No files matched your search

+92 -34
View File
@@ -7,23 +7,34 @@ import (
"testing"
"github.com/go-git/go-git/v6"
"github.com/go-git/go-git/v6/plumbing"
)
// TestResumeResetsToBranchTipNotBase pins the remediate workflow's worktree
// semantics: Resume must land the worktree on the PR branch's remote tip (the
// committed work), not reset to base the way refresh does for a fresh run.
func TestResumeResetsToBranchTipNotBase(t *testing.T) {
ctx := context.Background()
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
// headHash reads a worktree's HEAD commit, so a test can assert which commit a
// prepare landed on.
func headHash(t *testing.T, dir string) plumbing.Hash {
t.Helper()
r, err := git.PlainOpen(dir)
if err != nil {
t.Fatalf("PlainOpen(%s): %v", dir, err)
}
ref, err := r.Head()
if err != nil {
t.Fatalf("Head(%s): %v", dir, err)
}
return ref.Hash()
}
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: add widget", "", "feature")
// prepareResume models what a task retry starts from: a fresh prepare, a commit
// pushed onto the task branch, and the pushed tip. It returns the worktree
// directory, branch and tip.
func prepareResume(t *testing.T, m *Manager, issue int, title string) (dir, branch string, tip plumbing.Hash) {
t.Helper()
ctx := context.Background()
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, issue, title, "", "bug", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
// Commit + push work on the branch, so origin/<branch> has widget.go
// while base (main) has only README.
r, err := git.PlainOpen(dir)
if err != nil {
t.Fatalf("PlainOpen: %v", err)
@@ -32,51 +43,98 @@ func TestResumeResetsToBranchTipNotBase(t *testing.T) {
if err := m.Push(ctx, dir, branch); err != nil {
t.Fatalf("Push() error = %v", err)
}
return dir, branch, headHash(t, dir)
}
if err := m.Resume(ctx, dir, branch); err != nil {
t.Fatalf("Resume() error = %v", err)
// TestPrepareResumeLandsOnTheBranchTipNotBase pins the resume target's
// semantics: it must land the worktree on the PR branch's remote tip (the
// committed work), not reset to base the way a fresh prepare does.
func TestPrepareResumeLandsOnTheBranchTipNotBase(t *testing.T) {
ctx := context.Background()
m := newManager(t, newLocalRemote(t, "acme", "todo"))
dir, branch, tip := prepareResume(t, m, 7, "feat: add widget")
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: add widget", "", "bug", Target(branch)); err != nil {
t.Fatalf("Prepare(resume) error = %v", err)
}
content, err := os.ReadFile(filepath.Join(dir, "widget.go"))
if err != nil {
t.Fatalf("widget.go missing after Resume: %v (resume reset to base and discarded the branch work)", err)
t.Fatalf("widget.go missing after resume: %v (resume reset to base and discarded the branch work)", err)
}
if string(content) != "package widget\n" {
t.Fatalf("widget.go = %q, want %q", content, "package widget\n")
}
if got := headHash(t, dir); got != tip {
t.Fatalf("HEAD = %s, want the branch tip %s", got, tip)
}
}
// TestResumeCleansAbandonedFiles ensures Resume clears untracked residue the
// way refresh does, so a prior interrupted remediation cannot leak files into
// the next run.
func TestResumeCleansAbandonedFiles(t *testing.T) {
// TestPrepareResumeClonesAMissingWorktree is the root-cause test for
// archie-core-866m: a resume must create the clone when it is missing, so a
// retry reaches a task whose worktree the terminal cleanup removed, an expired
// volume dropped, or a different host never had.
func TestPrepareResumeClonesAMissingWorktree(t *testing.T) {
ctx := context.Background()
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
m := newManager(t, newLocalRemote(t, "acme", "todo"))
dir, branch, tip := prepareResume(t, m, 8, "fix: thing")
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 8, "fix: thing", "", "bug")
if err := os.RemoveAll(dir); err != nil {
t.Fatalf("remove worktree: %v", err)
}
if _, err := os.Stat(filepath.Join(dir, preparedSentinel)); !os.IsNotExist(err) {
t.Fatalf("worktree not removed: sentinel stat err = %v", err)
}
gotDir, gotBranch, err := m.Prepare(ctx, "acme", "todo", testBase, 8, "fix: thing", "", "bug", Target(branch))
if err != nil {
t.Fatalf("Prepare() error = %v", err)
t.Fatalf("Prepare(resume) on a missing worktree error = %v, want it cloned", err)
}
// The branch must be pushed for Resume to resolve origin/<branch>.
r, err := git.PlainOpen(dir)
if gotDir != dir || gotBranch != branch {
t.Fatalf("Prepare(resume) = (%q, %q), want (%q, %q)", gotDir, gotBranch, dir, branch)
}
content, err := os.ReadFile(filepath.Join(gotDir, "widget.go"))
if err != nil {
t.Fatalf("PlainOpen: %v", err)
t.Fatalf("widget.go missing after resume cloned: %v", err)
}
writeSeedCommit(t, r, dir, "change.go", "package change\n", "a change")
if err := m.Push(ctx, dir, branch); err != nil {
t.Fatalf("Push() error = %v", err)
if string(content) != "package widget\n" {
t.Fatalf("widget.go = %q, want %q", content, "package widget\n")
}
if got := headHash(t, gotDir); got != tip {
t.Fatalf("HEAD = %s, want the branch tip %s", got, tip)
}
}
// TestPrepareResumeFailsClosedWhenTheBranchIsNotPushed pins that a resume
// never falls back to base: a branch that is not on the remote is a dispatch
// defect, and a base checkout would silently remediate the wrong tree.
func TestPrepareResumeFailsClosedWhenTheBranchIsNotPushed(t *testing.T) {
ctx := context.Background()
m := newManager(t, newLocalRemote(t, "acme", "todo"))
dir, _, tip := prepareResume(t, m, 9, "fix: thing")
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "fix: thing", "", "bug", Target("fix/9-never-pushed")); err == nil {
t.Fatal("Prepare(resume) with an unpushed branch = nil error, want a fail-closed error")
}
if got := headHash(t, dir); got != tip {
t.Fatalf("HEAD = %s, want the worktree left on the branch tip %s", got, tip)
}
}
// TestPrepareResumeCleansAbandonedFiles ensures a resume clears untracked
// residue the way a fresh prepare does, so a prior interrupted run cannot leak
// files into the next commit.
func TestPrepareResumeCleansAbandonedFiles(t *testing.T) {
ctx := context.Background()
m := newManager(t, newLocalRemote(t, "acme", "todo"))
dir, branch, _ := prepareResume(t, m, 10, "fix: thing")
// Untracked residue that a clean run must remove.
if err := os.WriteFile(filepath.Join(dir, "scratch.txt"), []byte("junk\n"), 0o600); err != nil {
t.Fatal(err)
}
if err := m.Resume(ctx, dir, branch); err != nil {
t.Fatalf("Resume() error = %v", err)
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 10, "fix: thing", "", "bug", Target(branch)); err != nil {
t.Fatalf("Prepare(resume) error = %v", err)
}
if _, err := os.Stat(filepath.Join(dir, "scratch.txt")); !os.IsNotExist(err) {
t.Errorf("scratch.txt still exists after Resume; untracked residue was not cleaned")
t.Errorf("scratch.txt still exists after resume; untracked residue was not cleaned")
}
}
+73 -39
View File
@@ -120,70 +120,103 @@ func (m *Manager) signature() *object.Signature {
return &object.Signature{Name: m.BotUser, Email: m.BotEmail, When: time.Now()}
}
// Prepare creates a fresh clone for the task and checks out its branch.
// Any leftover worktree from a prior attempt is removed first. If the
// worktree is already prepared, it is refreshed and reused.
// Target selects the commit a prepared worktree is positioned at.
//
// The zero value is Fresh: a run that starts new work is reset onto
// origin/<base>. A non-empty Target is a resume: the worktree is reset onto
// origin/<that branch>, continuing the work an earlier attempt already pushed.
//
// The branch travels with the choice rather than being recomputed from the
// title, because a resume must land on the branch the open pull request lives
// on: a retitled issue would otherwise name a branch that does not exist.
//
// It is a string rather than a bool or an enum precisely so the branch to
// resume onto is carried by the choice; a bool would force a second parameter
// and let a caller select a resume without naming what it resumes onto.
type Target string
// Fresh is the fresh-run target: reset onto origin/<base>.
const Fresh Target = ""
// Prepare creates (or reuses) the task's clone and positions it on target,
// returning the worktree directory and the branch it is on.
//
// A missing clone is created for either target. That is what lets a resume
// recover a worktree the terminal cleanup, an expired volume or a different
// host removed before a retry. Fresh lands it on origin/<base>; a resume lands
// it on origin/<branch> and fails closed when that branch is not on the remote
// rather than falling back to base.
func (m *Manager) Prepare(
ctx context.Context,
owner, repo, base string,
issue int,
title, body, labels string,
target Target,
) (dir, branch string, err error) {
if !ValidCoordinates(owner, repo, issue) {
return "", "", fmt.Errorf("invalid worktree coordinates")
}
dir = m.Dir(owner, repo, issue)
branch = archieBranch(issue, title, labels)
if target != Fresh {
branch = string(target)
}
prepared := false
if _, statErr := os.Stat(filepath.Join(dir, preparedSentinel)); statErr == nil {
if err := m.refresh(ctx, dir, base, branch); err != nil {
return "", "", err
prepared = true
} else {
migrated, migrateErr := m.migrateLegacy(owner, repo, issue, dir)
if migrateErr != nil {
return "", "", migrateErr
}
return dir, branch, nil
}
if migrated, migrateErr := m.migrateLegacy(owner, repo, issue, dir); migrateErr != nil {
return "", "", migrateErr
} else if migrated {
if err := m.refresh(ctx, dir, base, branch); err != nil {
return "", "", err
}
return dir, branch, nil
prepared = migrated
}
if !prepared {
if err := m.createClone(ctx, owner, repo, base, dir); err != nil {
return "", "", err
}
}
if err := m.sync(ctx, dir, base, branch, target); err != nil {
return "", "", err
}
return dir, branch, nil
}
// createClone removes whatever sits at dir, clones the task's repository there,
// records the bot identity and marks the worktree prepared. Prepare calls it
// only for a worktree it could not reuse.
func (m *Manager) createClone(ctx context.Context, owner, repo, base, dir string) error {
if err := os.RemoveAll(dir); err != nil {
return "", "", fmt.Errorf("clear stale worktree: %w", err)
return fmt.Errorf("clear stale worktree: %w", err)
}
if err := os.MkdirAll(filepath.Dir(dir), 0o755); err != nil {
return "", "", fmt.Errorf("create worktree parent: %w", err)
return fmt.Errorf("create worktree parent: %w", err)
}
r, err := git.PlainCloneContext(ctx, dir, &git.CloneOptions{
URL: m.cloneURL(owner, repo),
ClientOptions: m.auth(),
ReferenceName: plumbing.NewBranchReferenceName(base),
})
if err != nil {
return "", "", fmt.Errorf("clone %s/%s: %w", owner, repo, err)
return fmt.Errorf("clone %s/%s: %w", owner, repo, err)
}
if err := m.setIdentity(r); err != nil {
return "", "", err
return err
}
return writeSentinel(dir)
}
wt, err := r.Worktree()
if err != nil {
return "", "", fmt.Errorf("open worktree: %w", err)
// sync positions an already-prepared worktree: Fresh resets it onto
// origin/<base>; a resume resets it onto origin/<branch>. Both fetch first and
// clear the worktree against the target tree before committing to it.
func (m *Manager) sync(ctx context.Context, dir, base, branch string, target Target) error {
if target == Fresh {
return m.refresh(ctx, dir, base, branch)
}
if err := wt.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewBranchReferenceName(branch),
Create: true,
}); err != nil {
return "", "", fmt.Errorf("create branch %s: %w", branch, err)
}
if err := writeSentinel(dir); err != nil {
return "", "", err
}
return dir, branch, nil
return m.resume(ctx, dir, branch)
}
func (m *Manager) legacyDir(owner, repo string, issue int) string {
@@ -256,12 +289,13 @@ func (m *Manager) refresh(ctx context.Context, dir, base, branch string) error {
return resetOnto(r, dir, branch, baseHash, remoteBase(base))
}
// Resume re-syncs an already-prepared worktree onto its branch's remote tip
// without resetting to base, so the remediate workflow can continue work on
// the PR branch the implement run already pushed. It is refresh's complement:
// refresh resets to origin/<base> for a fresh run; Resume resets to
// origin/<branch> so the committed PR work survives.
func (m *Manager) Resume(ctx context.Context, dir, branch string) error {
// resume re-syncs an already-prepared worktree onto its branch's remote tip
// without resetting to base, so a remediation can continue work on the PR
// branch an earlier attempt already pushed. It is refresh's complement: refresh
// resets to origin/<base> for a fresh run; resume resets to origin/<branch> so
// the committed PR work survives. It is reached through Prepare's Target, and
// the worktree it opens is one Prepare has already cloned when it was missing.
func (m *Manager) resume(ctx context.Context, dir, branch string) error {
r, err := git.PlainOpen(dir)
if err != nil {
return fmt.Errorf("open prepared worktree: %w", err)
+3 -3
View File
@@ -88,7 +88,7 @@ func TestPushSucceedsWhenPostPublicationMetadataFails(t *testing.T) {
m.Log = slog.New(logs)
}
dir, branch, err := m.Prepare(ctx, "acme", "push-test", testBase, tc.issue, tc.title, "", tc.labels)
dir, branch, err := m.Prepare(ctx, "acme", "push-test", testBase, tc.issue, tc.title, "", tc.labels, Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -178,7 +178,7 @@ func TestRecordUpstreamErrorPaths(t *testing.T) {
host := newLocalRemote(t, "acme", "record-upstream")
m := newManager(t, host)
dir, branch, err := m.Prepare(ctx, "acme", "record-upstream", testBase, 105, "feat: record upstream", "", "feature")
dir, branch, err := m.Prepare(ctx, "acme", "record-upstream", testBase, 105, "feat: record upstream", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -229,7 +229,7 @@ func TestCommitAllHonoursCancellation(t *testing.T) {
host := newLocalRemote(t, "acme", "cancel-test")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "cancel-test", testBase, 201, "feat: cancel test", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "cancel-test", testBase, 201, "feat: cancel test", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
+24 -24
View File
@@ -120,7 +120,7 @@ func TestPrepareCommitPushRoundTrip(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: add widget", "", "feature")
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: add widget", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -194,7 +194,7 @@ func TestPrepareIsIdempotent(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir1, branch1, err := m.Prepare(ctx, "acme", "todo", testBase, 3, "fix: thing", "", "bug")
dir1, branch1, err := m.Prepare(ctx, "acme", "todo", testBase, 3, "fix: thing", "", "bug", Fresh)
if err != nil {
t.Fatalf("first Prepare() error = %v", err)
}
@@ -205,7 +205,7 @@ func TestPrepareIsIdempotent(t *testing.T) {
t.Fatal(err)
}
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 3, "fix: thing", "", "bug")
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 3, "fix: thing", "", "bug", Fresh)
if err != nil {
t.Fatalf("second Prepare() error = %v", err)
}
@@ -260,7 +260,7 @@ func TestPrepareRecoversFromADirtyWorktreeOnRetry(t *testing.T) {
}
m := newManager(t, host)
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "fix: retry robustness", "", "bug")
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "fix: retry robustness", "", "bug", Fresh)
if err != nil {
t.Fatalf("first Prepare() error = %v", err)
}
@@ -280,7 +280,7 @@ func TestPrepareRecoversFromADirtyWorktreeOnRetry(t *testing.T) {
t.Fatal(err)
}
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "fix: retry robustness", "", "bug")
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "fix: retry robustness", "", "bug", Fresh)
if err != nil {
t.Fatalf("retry Prepare() on a dirty worktree error = %v, want recovery", err)
}
@@ -384,13 +384,13 @@ func TestPrepareRecoversFromAPathTypeConflictOnRetry(t *testing.T) {
seedTrackedPath(t, host, "pkg/a.txt", "a\n")
m := newManager(t, host)
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "fix: path type conflict", "", "bug")
dir, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "fix: path type conflict", "", "bug", Fresh)
if err != nil {
t.Fatalf("first Prepare() error = %v", err)
}
c.wreck(t, dir)
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "fix: path type conflict", "", "bug")
dir2, branch2, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "fix: path type conflict", "", "bug", Fresh)
if err != nil {
t.Fatalf("retry Prepare() over a path type conflict error = %v, want recovery", err)
}
@@ -439,7 +439,7 @@ func TestPrepareCreatesTheBranchWhenItIsGenuinelyMissing(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "fix: first title", "", "bug")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "fix: first title", "", "bug", Fresh)
if err != nil {
t.Fatalf("first Prepare() error = %v", err)
}
@@ -452,7 +452,7 @@ func TestPrepareCreatesTheBranchWhenItIsGenuinelyMissing(t *testing.T) {
t.Fatalf("remove branch %s: %v", first, err)
}
_, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "fix: renamed title", "", "bug")
_, branch, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "fix: renamed title", "", "bug", Fresh)
if err != nil {
t.Fatalf("Prepare() after the branch was removed error = %v, want it created", err)
}
@@ -506,7 +506,7 @@ func TestCleanUntrackedHandlesGitdirFile(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 12, "fix: gitdir file", "", "bug")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 12, "fix: gitdir file", "", "bug", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -591,7 +591,7 @@ func TestPrepareDiscardsDirectoryWithoutSentinel(t *testing.T) {
t.Fatal(err)
}
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 11, "chore: retry", "", "chore"); err != nil {
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 11, "chore: retry", "", "chore", Fresh); err != nil {
t.Fatalf("Prepare() error = %v", err)
}
if _, err := os.Stat(junk); !os.IsNotExist(err) {
@@ -619,7 +619,7 @@ func TestPrepareErrors(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
m := newManager(t, tc.host)
_, _, err := m.Prepare(context.Background(), tc.owner, tc.repo, tc.base, 1, "t", "", "")
_, _, err := m.Prepare(context.Background(), tc.owner, tc.repo, tc.base, 1, "t", "", "", Fresh)
if err == nil {
t.Fatal("Prepare() error = nil, want a failure")
}
@@ -631,10 +631,10 @@ func TestPrepareRefreshRejectsUnknownBase(t *testing.T) {
ctx := context.Background()
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 12, "fix: base", "", "bug"); err != nil {
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 12, "fix: base", "", "bug", Fresh); err != nil {
t.Fatal(err)
}
if _, _, err := m.Prepare(ctx, "acme", "todo", "missing-base", 12, "fix: base", "", "bug"); err == nil {
if _, _, err := m.Prepare(ctx, "acme", "todo", "missing-base", 12, "fix: base", "", "bug", Fresh); err == nil {
t.Fatal("prepared worktree accepted an unknown base")
}
}
@@ -682,7 +682,7 @@ func TestSnapshotExportsTrackedFilesWithoutGit(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "feat: snapshot me", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 9, "feat: snapshot me", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -718,7 +718,7 @@ func TestDiffUsesMergeBaseNotRemoteTip(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 5, "feat: mine", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 5, "feat: mine", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -771,7 +771,7 @@ func TestDiffOperationsRejectUnrelatedBaseHistory(t *testing.T) {
ctx := context.Background()
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 6, "feat: task", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 6, "feat: task", "", "feature", Fresh)
if err != nil {
t.Fatal(err)
}
@@ -886,7 +886,7 @@ func TestPushWithoutTokenOverHTTPFailsWithClearMessage(t *testing.T) {
ctx := context.Background()
host := newLocalRemote(t, "acme", "todo")
seeder := newManager(t, host)
dir, branch, err := seeder.Prepare(ctx, "acme", "todo", testBase, 1, "t", "", "")
dir, branch, err := seeder.Prepare(ctx, "acme", "todo", testBase, 1, "t", "", "", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -973,7 +973,7 @@ func TestPrepareMigratesMatchingLegacyWorktree(t *testing.T) {
t.Fatal(err)
}
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 44, "feat: migrate", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 44, "feat: migrate", "", "feature", Fresh)
if err != nil {
t.Fatal(err)
}
@@ -1008,7 +1008,7 @@ func TestPreparePreservesMismatchedLegacyWorktree(t *testing.T) {
t.Fatal(err)
}
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 45, "feat: safe migration", "", "feature"); err != nil {
if _, _, err := m.Prepare(ctx, "acme", "todo", testBase, 45, "feat: safe migration", "", "feature", Fresh); err != nil {
t.Fatal(err)
}
if _, err := os.Stat(marker); err != nil {
@@ -1059,7 +1059,7 @@ func TestSentinelIsNeverCommitted(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "feat: thing", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 21, "feat: thing", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -1097,7 +1097,7 @@ func TestTaskBriefIsNeverCommitted(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "feat: brief", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 22, "feat: brief", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -1397,7 +1397,7 @@ func TestChangedFileStatsRecordsTheDiffedBaseNotTheAdvancedTip(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 8, "feat: mine", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 8, "feat: mine", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}
@@ -1473,7 +1473,7 @@ func TestHasUncommittedChangesReportsWorkNoCommitHasCaptured(t *testing.T) {
host := newLocalRemote(t, "acme", "todo")
m := newManager(t, host)
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: mine", "", "feature")
dir, _, err := m.Prepare(ctx, "acme", "todo", testBase, 7, "feat: mine", "", "feature", Fresh)
if err != nil {
t.Fatalf("Prepare() error = %v", err)
}