fix(worktree): gate sessions on bootstrap readiness (#1762)
Co-authored-by: Leonid Skorobogatyy <bash@opencode.itc.local> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Leonid Skorobogatyy
Bohdan Triapitsyn
parent
03e6f789a4
commit
8c1a24089d
@@ -3550,6 +3550,19 @@ export async function validateWorktreeCreate(directory, input = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
const assertWorktreeCreatePreflight = async (directory, input = {}) => {
|
||||
const validation = await validateWorktreeCreate(directory, input);
|
||||
if (validation?.ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = validation?.errors
|
||||
?.map((error) => error?.message)
|
||||
.filter(Boolean)
|
||||
.join('\n') || 'Failed to validate worktree creation';
|
||||
throw new Error(message);
|
||||
};
|
||||
|
||||
export async function previewWorktreeCreate(directory, input = {}) {
|
||||
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
||||
const context = await resolveWorktreeProjectContext(directory);
|
||||
@@ -3698,6 +3711,11 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
|
||||
export async function createWorktree(directory, input = {}) {
|
||||
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
||||
const context = await resolveWorktreeProjectContext(directory);
|
||||
|
||||
if (input?.returnAfterDirectoryCreated === true) {
|
||||
await assertWorktreeCreatePreflight(directory, input);
|
||||
}
|
||||
|
||||
await fsp.mkdir(context.worktreeRoot, { recursive: true });
|
||||
|
||||
const preferredName = String(input?.worktreeName || input?.name || '').trim();
|
||||
|
||||
Reference in New Issue
Block a user