amalgm 0.1.182 → 0.1.183
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/package.json
CHANGED
|
@@ -415,6 +415,41 @@ test('a losing commit is parked, the winning card lands exactly, and losing work
|
|
|
415
415
|
assert.deepEqual(readRepoState('root:test').parked.map((entry) => entry.oid), [losingOid]);
|
|
416
416
|
});
|
|
417
417
|
|
|
418
|
+
test('a new card folds checkpoint work already on the rail instead of replaying it as local work', async () => {
|
|
419
|
+
const { repo, oid: baseOid } = await makeRepo('card-folds-shared-checkpoint');
|
|
420
|
+
const sharedPatch = await patchFor(repo, { 'a.txt': 'shared checkpoint\n' });
|
|
421
|
+
|
|
422
|
+
await git(repo, 'switch', '-c', 'target');
|
|
423
|
+
fs.writeFileSync(path.join(repo, 'a.txt'), 'shared checkpoint\n');
|
|
424
|
+
await git(repo, 'add', 'a.txt');
|
|
425
|
+
await git(repo, 'commit', '-m', 'commit shared checkpoint');
|
|
426
|
+
const targetOid = (await git(repo, 'rev-parse', 'HEAD')).trim();
|
|
427
|
+
await git(repo, 'switch', 'main');
|
|
428
|
+
|
|
429
|
+
const oldCard = card(repo, baseOid, 1);
|
|
430
|
+
await materializeRepo(oldCard, {
|
|
431
|
+
repoKey: 'root:test',
|
|
432
|
+
card: oldCard,
|
|
433
|
+
transitions: [transition('machine-remote', 2, baseOid, '', sharedPatch)],
|
|
434
|
+
});
|
|
435
|
+
assert.notEqual((await git(repo, 'status', '--porcelain')).trim(), '');
|
|
436
|
+
|
|
437
|
+
const outcome = await materializeRepo(oldCard, {
|
|
438
|
+
repoKey: 'root:test',
|
|
439
|
+
card: {
|
|
440
|
+
...oldCard,
|
|
441
|
+
head: { branch: 'main', oid: targetOid, detached: false },
|
|
442
|
+
positionVersion: 3,
|
|
443
|
+
positionMutationId: 'mut_card_shared_fold',
|
|
444
|
+
},
|
|
445
|
+
transitions: [],
|
|
446
|
+
parked: [],
|
|
447
|
+
});
|
|
448
|
+
assert.equal(outcome.state, 'in-sync');
|
|
449
|
+
assert.equal((await git(repo, 'rev-parse', 'HEAD')).trim(), targetOid);
|
|
450
|
+
assert.equal((await git(repo, 'status', '--porcelain')).trim(), '');
|
|
451
|
+
});
|
|
452
|
+
|
|
418
453
|
test('checkpoint then commit folds through the same card movement and unrelated local work stays', async () => {
|
|
419
454
|
const { repo, oid: baseOid } = await makeRepo('checkpoint-commit-fold');
|
|
420
455
|
await git(repo, 'switch', '-c', 'target');
|
|
@@ -230,6 +230,15 @@ async function moveToWinningCard(localCard, targetCard) {
|
|
|
230
230
|
return { state: 'waiting', reason: 'local-state-moving' };
|
|
231
231
|
}
|
|
232
232
|
const repoKey = repoKeyOfCard(localCard);
|
|
233
|
+
const reducedState = readRepoState(repoKey);
|
|
234
|
+
const capturedOnRail = reducedState?.baseOid === current.head.oid
|
|
235
|
+
&& reducedState.checkpointRevision === revisionOf(
|
|
236
|
+
current.head.oid,
|
|
237
|
+
captured.indexDiff,
|
|
238
|
+
captured.worktreeDiff,
|
|
239
|
+
);
|
|
240
|
+
const movingIndexDiff = capturedOnRail ? '' : captured.indexDiff;
|
|
241
|
+
const movingWorktreeDiff = capturedOnRail ? '' : captured.worktreeDiff;
|
|
233
242
|
const parked = [];
|
|
234
243
|
if (!forward && current.head.oid !== targetCard.head.oid) {
|
|
235
244
|
const parkedRef = await transition.parkCommit(localCard.path, current.head.oid);
|
|
@@ -257,7 +266,7 @@ async function moveToWinningCard(localCard, targetCard) {
|
|
|
257
266
|
oldTree,
|
|
258
267
|
{ label: `parked-${current.head.oid.slice(0, 12)}` },
|
|
259
268
|
);
|
|
260
|
-
const oldIndexTree = await merge.treeOfPatch(localCard.path, current.head.oid,
|
|
269
|
+
const oldIndexTree = await merge.treeOfPatch(localCard.path, current.head.oid, movingIndexDiff);
|
|
261
270
|
const staged = await merge.reduceTree(
|
|
262
271
|
localCard.path,
|
|
263
272
|
committed.tree,
|
|
@@ -265,7 +274,7 @@ async function moveToWinningCard(localCard, targetCard) {
|
|
|
265
274
|
oldIndexTree,
|
|
266
275
|
{ label: `staged-${current.head.oid.slice(0, 12)}` },
|
|
267
276
|
);
|
|
268
|
-
const oldWorktree = await merge.treeOfPatch(localCard.path, oldIndexTree,
|
|
277
|
+
const oldWorktree = await merge.treeOfPatch(localCard.path, oldIndexTree, movingWorktreeDiff);
|
|
269
278
|
const working = await merge.reduceTree(
|
|
270
279
|
localCard.path,
|
|
271
280
|
staged.tree,
|