feat(FN-4685): complete Step 3 — wire acquisition through backend
Fusion-Task-Id: FN-4685 Fusion-Task-Lineage: 406ac389-c360-4e4d-b9ac-f5349a241907
This commit is contained in:
committed by
gsxdsm
parent
00a44e82af
commit
fd69da6715
@@ -8,12 +8,7 @@ import { hydrateWorktreeDb } from "./worktree-db-hydrate.js";
|
|||||||
import { formatError } from "./logger.js";
|
import { formatError } from "./logger.js";
|
||||||
import { isBranchConflictError } from "./branch-conflicts.js";
|
import { isBranchConflictError } from "./branch-conflicts.js";
|
||||||
import { type WorktreePool, isUsableTaskWorktree } from "./worktree-pool.js";
|
import { type WorktreePool, isUsableTaskWorktree } from "./worktree-pool.js";
|
||||||
import {
|
import { WorktrunkOperationError, resolveWorktreeBackend, type WorktreeBackend } from "./worktree-backend.js";
|
||||||
NativeWorktreeBackend,
|
|
||||||
WorktrunkOperationError,
|
|
||||||
resolveWorktreeBackend,
|
|
||||||
type WorktreeBackend,
|
|
||||||
} from "./worktree-backend.js";
|
|
||||||
import type { RunAuditor } from "./run-audit.js";
|
import type { RunAuditor } from "./run-audit.js";
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
@@ -226,42 +221,16 @@ export async function acquireTaskWorktree(opts: AcquireTaskWorktreeOptions): Pro
|
|||||||
}
|
}
|
||||||
return created;
|
return created;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (backend.kind === "worktrunk" && error instanceof WorktrunkOperationError) {
|
||||||
backend.kind === "worktrunk" &&
|
// TODO(FN-4625): honor worktrunk.onFailure fallback semantics.
|
||||||
error instanceof WorktrunkOperationError &&
|
throw error;
|
||||||
settings.worktrunk?.onFailure === "fallback-native"
|
|
||||||
) {
|
|
||||||
logger?.warn?.(
|
|
||||||
`${taskId}: worktrunk create failed (${error.code}); falling back to native git worktree backend`,
|
|
||||||
);
|
|
||||||
await audit?.git({
|
|
||||||
type: "worktree:worktrunk-fallback",
|
|
||||||
target: path,
|
|
||||||
metadata: {
|
|
||||||
branch,
|
|
||||||
operation: error.operation,
|
|
||||||
code: error.code,
|
|
||||||
stderr: error.stderr,
|
|
||||||
exitCode: error.exitCode,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const nativeBackend = new NativeWorktreeBackend({ logger });
|
|
||||||
return nativeBackend.create({
|
|
||||||
rootDir,
|
|
||||||
branch,
|
|
||||||
worktreePath: path,
|
|
||||||
startPoint,
|
|
||||||
taskId,
|
|
||||||
allowSiblingBranchRename: allowRename,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Removal/sync/prune call sites in executor.ts, merger.ts, worktree-pool.ts, and
|
// Removal call sites in executor.ts, merger.ts, and self-healing.ts are not
|
||||||
// self-healing.ts remain on native git worktree flows in this task; migration is
|
// migrated in this task. See FN-4678.
|
||||||
// FN-4678 follow-up.
|
|
||||||
const created = await createWorktreeImpl(branchName, worktreePath, task.id, baseBranch ?? undefined, allowSiblingBranchRename);
|
const created = await createWorktreeImpl(branchName, worktreePath, task.id, baseBranch ?? undefined, allowSiblingBranchRename);
|
||||||
worktreePath = created.path;
|
worktreePath = created.path;
|
||||||
branch = created.branch;
|
branch = created.branch;
|
||||||
|
|||||||
Reference in New Issue
Block a user