@paleo/worktree-env 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/setup-worktree.js +28 -3
- package/package.json +1 -1
package/dist/setup-worktree.js
CHANGED
|
@@ -66,7 +66,7 @@ export async function runSetupWorktree(config) {
|
|
|
66
66
|
}
|
|
67
67
|
const { slot } = await runSetup(args, ctx, run, config);
|
|
68
68
|
if (isWaitMode(args)) {
|
|
69
|
-
await waitForSlot(slot, config);
|
|
69
|
+
await waitForSlot(slot, config, { printSummary: false });
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
async function runSetup(args, ctx, run, config) {
|
|
@@ -79,6 +79,7 @@ async function runSetup(args, ctx, run, config) {
|
|
|
79
79
|
scheme,
|
|
80
80
|
});
|
|
81
81
|
const setupCtx = ensureWorktree(args, ctx, run, config.worktreeDirName);
|
|
82
|
+
refuseIfFinalizePending(setupCtx, config.registryDir, args.force ?? false);
|
|
82
83
|
const branch = getCurrentBranch(setupCtx.currentWorktree);
|
|
83
84
|
const { port: slot, owner } = resolveAndRegisterSlot({
|
|
84
85
|
slot: args.slot,
|
|
@@ -143,6 +144,20 @@ async function runSetup(args, ctx, run, config) {
|
|
|
143
144
|
closeSync(logFd);
|
|
144
145
|
return { slot };
|
|
145
146
|
}
|
|
147
|
+
function refuseIfFinalizePending(ctx, registryDir, force) {
|
|
148
|
+
if (force)
|
|
149
|
+
return;
|
|
150
|
+
const registry = readSlots(ctx.mainWorktree, registryDir);
|
|
151
|
+
const resolvedCurrent = resolve(ctx.currentWorktree);
|
|
152
|
+
const found = Object.entries(registry.slots).find(([, e]) => resolve(e.worktree) === resolvedCurrent && e.status === "pending");
|
|
153
|
+
if (!found)
|
|
154
|
+
return;
|
|
155
|
+
const [slotPort] = found;
|
|
156
|
+
console.error(`Error: Setup is already in progress for slot ${slotPort}. ` +
|
|
157
|
+
`Run 'setup-worktree --wait --slot ${slotPort}' to wait for it to finish (or fail), ` +
|
|
158
|
+
"then retry. Use --force to bypass.");
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
146
161
|
async function runFinalize(args, config) {
|
|
147
162
|
const slot = Number(args.__finalize);
|
|
148
163
|
const ctx = detectWorktree();
|
|
@@ -242,10 +257,12 @@ function runInfo(args, config) {
|
|
|
242
257
|
printWorktreeInfo(config, resolved.slot, ".", { branch: resolved.branch, owner: resolved.owner });
|
|
243
258
|
}
|
|
244
259
|
async function runWait(args, config) {
|
|
260
|
+
// standalone --wait (no prior setup in this invocation) → print the full summary on success.
|
|
245
261
|
const slot = resolveTargetSlot(args, config);
|
|
246
262
|
await waitForSlot(slot, config);
|
|
247
263
|
}
|
|
248
|
-
async function waitForSlot(slot, config) {
|
|
264
|
+
async function waitForSlot(slot, config, options = {}) {
|
|
265
|
+
const printSummary = options.printSummary ?? true;
|
|
249
266
|
const ctx = detectWorktree();
|
|
250
267
|
const initial = readSlots(ctx.mainWorktree, config.registryDir).slots[String(slot)];
|
|
251
268
|
if (!initial) {
|
|
@@ -262,7 +279,15 @@ async function waitForSlot(slot, config) {
|
|
|
262
279
|
process.exit(1);
|
|
263
280
|
}
|
|
264
281
|
if (entry.status === "ready") {
|
|
265
|
-
|
|
282
|
+
if (printSummary) {
|
|
283
|
+
printWorktreeInfo(config, slot, entry.worktree, {
|
|
284
|
+
branch: entry.branch,
|
|
285
|
+
owner: entry.owner,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
console.log("Status: ready");
|
|
290
|
+
}
|
|
266
291
|
return;
|
|
267
292
|
}
|
|
268
293
|
if (entry.status === "failed") {
|