@ghl-ai/aw 0.1.36-beta.102 → 0.1.36-beta.103
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/git.mjs +26 -1
- package/package.json +1 -1
package/git.mjs
CHANGED
|
@@ -294,14 +294,39 @@ export async function fetchAndMerge(awHome, { silent = true } = {}) {
|
|
|
294
294
|
const conflicts = [];
|
|
295
295
|
|
|
296
296
|
// ── 3. Fast-forward (no local commits ahead of remote) ───────────────────
|
|
297
|
+
// Snapshot sparse paths before merge — git 2.46+ silently disables
|
|
298
|
+
// sparse-checkout on blob:none repos when ff-only actually advances HEAD.
|
|
299
|
+
let sparsePaths = [];
|
|
300
|
+
try {
|
|
301
|
+
const { stdout: listOut } = await exec(`git -C "${awHome}" sparse-checkout list`);
|
|
302
|
+
sparsePaths = listOut.trim().split('\n').filter(Boolean);
|
|
303
|
+
} catch { /* sparse checkout not active */ }
|
|
304
|
+
|
|
305
|
+
let ffSucceeded = false;
|
|
297
306
|
try {
|
|
298
307
|
const { stdout } = await exec(
|
|
299
308
|
`git -C "${awHome}" merge origin/${REGISTRY_BASE_BRANCH} --ff-only`,
|
|
300
309
|
);
|
|
301
310
|
updated = !stdout.includes('Already up to date');
|
|
302
|
-
|
|
311
|
+
ffSucceeded = true;
|
|
303
312
|
} catch { /* local commits exist — fall through to rebase */ }
|
|
304
313
|
|
|
314
|
+
if (ffSucceeded) {
|
|
315
|
+
// Restore sparse checkout if git disabled it during the fast-forward
|
|
316
|
+
if (updated && sparsePaths.length > 0) {
|
|
317
|
+
try {
|
|
318
|
+
await exec(`git -C "${awHome}" sparse-checkout list`);
|
|
319
|
+
} catch {
|
|
320
|
+
try {
|
|
321
|
+
await exec(`git -C "${awHome}" sparse-checkout init --no-cone`);
|
|
322
|
+
await exec(`git -C "${awHome}" sparse-checkout set ${sparsePaths.map(p => `"${p}"`).join(' ')}`);
|
|
323
|
+
await exec(`git -C "${awHome}" checkout ${REGISTRY_BASE_BRANCH}`);
|
|
324
|
+
} catch { /* best effort */ }
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return { updated, conflicts };
|
|
328
|
+
}
|
|
329
|
+
|
|
305
330
|
// ── 4. Rebase current branch onto remote REGISTRY_BASE_BRANCH ────────────
|
|
306
331
|
// For push branches: stacks our local commits on top of latest remote.
|
|
307
332
|
// For base branch: only reached if local commits exist (unusual).
|