@ghl-ai/aw 0.1.36-beta.110 → 0.1.36-beta.112
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 +10 -40
- package/package.json +1 -1
package/git.mjs
CHANGED
|
@@ -293,46 +293,16 @@ export async function fetchAndMerge(awHome, { silent = true } = {}) {
|
|
|
293
293
|
let updated = false;
|
|
294
294
|
const conflicts = [];
|
|
295
295
|
|
|
296
|
-
// ── 3
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
//
|
|
302
|
-
//
|
|
303
|
-
//
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
// never lost.
|
|
307
|
-
let canFF = false;
|
|
308
|
-
try {
|
|
309
|
-
await exec(`git -C "${awHome}" merge-base --is-ancestor HEAD origin/${REGISTRY_BASE_BRANCH}`);
|
|
310
|
-
canFF = true;
|
|
311
|
-
} catch { /* local commits exist — not a fast-forward */ }
|
|
312
|
-
|
|
313
|
-
if (canFF) {
|
|
314
|
-
// Skip reset if there are local staged/unstaged changes — reset --hard
|
|
315
|
-
// would wipe them. The user needs to push first; we'll sync on the next
|
|
316
|
-
// pull after they do.
|
|
317
|
-
let hasLocalChanges = false;
|
|
318
|
-
try {
|
|
319
|
-
const { stdout: statusOut } = await exec(`git -C "${awHome}" status --porcelain`);
|
|
320
|
-
hasLocalChanges = statusOut.trim().length > 0;
|
|
321
|
-
} catch { /* ignore */ }
|
|
322
|
-
|
|
323
|
-
if (hasLocalChanges) return { updated: false, conflicts };
|
|
324
|
-
|
|
325
|
-
const { stdout: headBefore } = await exec(`git -C "${awHome}" rev-parse HEAD`);
|
|
326
|
-
await exec(`git -C "${awHome}" reset --hard origin/${REGISTRY_BASE_BRANCH}`);
|
|
327
|
-
const { stdout: headAfter } = await exec(`git -C "${awHome}" rev-parse HEAD`);
|
|
328
|
-
updated = headBefore.trim() !== headAfter.trim();
|
|
329
|
-
return { updated, conflicts };
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// ── 4. Rebase current branch onto remote REGISTRY_BASE_BRANCH ────────────
|
|
333
|
-
// For push branches: stacks our local commits on top of latest remote.
|
|
334
|
-
// For base branch: only reached if local commits exist (unusual).
|
|
335
|
-
// Never uses --no-edit merge — that disables sparse checkout on blob:none.
|
|
296
|
+
// ── 3 + 4. Rebase onto remote REGISTRY_BASE_BRANCH ──────────────────────
|
|
297
|
+
// Handles both cases in one path:
|
|
298
|
+
// • No local commits (base branch, clean tree) → fast-forward via rebase
|
|
299
|
+
// • Local commits (push branch) → rebases on top
|
|
300
|
+
// • Uncommitted local changes → rebase refuses to run,
|
|
301
|
+
// sync is skipped this run, changes are preserved
|
|
302
|
+
//
|
|
303
|
+
// We avoid `merge --ff-only` and `merge --no-edit` entirely: both trigger a
|
|
304
|
+
// git 2.46+ bug on blob:none + no-cone sparse-checkout repos that silently
|
|
305
|
+
// drops bare-name patterns (e.g. "content", "CODEOWNERS") when HEAD advances.
|
|
336
306
|
try {
|
|
337
307
|
await exec(`git -C "${awHome}" rebase origin/${REGISTRY_BASE_BRANCH}`);
|
|
338
308
|
updated = true;
|