amalgm 0.1.234 → 0.1.235
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
|
@@ -440,8 +440,22 @@ test('unchanged commits reuse their card object source and one new oid is resolv
|
|
|
440
440
|
|
|
441
441
|
test('only complete object sources are reusable', () => {
|
|
442
442
|
assert.deepEqual(
|
|
443
|
-
cardTest.reusableObjectSource(
|
|
444
|
-
|
|
443
|
+
cardTest.reusableObjectSource(
|
|
444
|
+
'a',
|
|
445
|
+
'a',
|
|
446
|
+
{ kind: 'bundle', resourceId: 'shr_project_a', checksum: 'ready' },
|
|
447
|
+
'shr_project_a',
|
|
448
|
+
),
|
|
449
|
+
{ kind: 'bundle', resourceId: 'shr_project_a', checksum: 'ready' },
|
|
450
|
+
);
|
|
451
|
+
assert.equal(
|
|
452
|
+
cardTest.reusableObjectSource(
|
|
453
|
+
'a',
|
|
454
|
+
'a',
|
|
455
|
+
{ kind: 'bundle', resourceId: 'shr_project_old', checksum: 'ready' },
|
|
456
|
+
'shr_project_new',
|
|
457
|
+
),
|
|
458
|
+
null,
|
|
445
459
|
);
|
|
446
460
|
assert.equal(cardTest.reusableObjectSource('a', 'b', { kind: 'remote' }), null);
|
|
447
461
|
assert.equal(cardTest.reusableObjectSource('a', 'a', { kind: 'pending' }), null);
|
|
@@ -60,10 +60,10 @@ function cardKind(classified) {
|
|
|
60
60
|
return classified.linked ? 'linked-worktree' : 'primary';
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function reusableObjectSource(previousOid, currentOid, source) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
function reusableObjectSource(previousOid, currentOid, source, resourceId) {
|
|
64
|
+
if (previousOid !== currentOid) return null;
|
|
65
|
+
if (source?.kind === 'remote') return source;
|
|
66
|
+
return source?.kind === 'bundle' && source.resourceId === resourceId ? source : null;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async function observeWorktree(classified, previousCard = null) {
|
|
@@ -83,6 +83,9 @@ async function observeWorktree(classified, previousCard = null) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const repoIdentity = remote === null ? null : remoteIdentity(remote);
|
|
86
|
+
const resourceId = repoIdentity
|
|
87
|
+
? require('./wall').projectForRepo(repoIdentity)?.resourceId
|
|
88
|
+
: null;
|
|
86
89
|
const previous = previousCard?.replica === replica.replicaId
|
|
87
90
|
&& previousCard.repo?.remote === repoIdentity
|
|
88
91
|
? previousCard
|
|
@@ -92,7 +95,7 @@ async function observeWorktree(classified, previousCard = null) {
|
|
|
92
95
|
const sourceFor = (oid, priorOid, priorSource) => {
|
|
93
96
|
if (!oid || !repoIdentity) return null;
|
|
94
97
|
if (objectSources.has(oid)) return objectSources.get(oid);
|
|
95
|
-
const source = reusableObjectSource(priorOid, oid, priorSource)
|
|
98
|
+
const source = reusableObjectSource(priorOid, oid, priorSource, resourceId)
|
|
96
99
|
|| require('./objects').objectSourceFor(worktreeRoot, repoIdentity, oid);
|
|
97
100
|
objectSources.set(oid, source);
|
|
98
101
|
return source;
|