@ibgib/vcs-gib 0.0.30 → 0.0.33
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/AUTO-GENERATED-version.d.mts +1 -1
- package/dist/AUTO-GENERATED-version.mjs +1 -1
- package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
- package/dist/bootstrap/node-bootstrap.mjs +7 -21
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +3 -4
- package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-add-cmd.mjs +45 -0
- package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
- package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +9 -9
- package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
- package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-checkout-cmd.d.mts +20 -0
- package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-commit-cmd.d.mts +23 -0
- package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
- package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +11 -6
- package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
- package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +3 -3
- package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-init-cmd.mjs +47 -0
- package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
- package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +3 -4
- package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-log-cmd.mjs +90 -0
- package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-merge-cmd.d.mts +22 -0
- package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
- package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
- package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +2 -2
- package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
- package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-restore-cmd.d.mts +23 -0
- package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
- package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
- package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +3 -3
- package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-status-cmd.mjs +96 -0
- package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
- package/dist/cli/vcs-cli-main.d.mts.map +1 -1
- package/dist/cli/vcs-cli-main.mjs +18 -15
- package/dist/cli/vcs-cli-main.mjs.map +1 -1
- package/dist/cli/vcs-projection-helper.d.mts +23 -0
- package/dist/cli/vcs-projection-helper.d.mts.map +1 -0
- package/dist/cli/vcs-projection-helper.mjs +91 -0
- package/dist/cli/vcs-projection-helper.mjs.map +1 -0
- package/dist/cli/vcs-repo-helper.d.mts +19 -0
- package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
- package/dist/cli/vcs-repo-helper.mjs +74 -0
- package/dist/cli/vcs-repo-helper.mjs.map +1 -0
- package/dist/test/test-helpers.d.mts +11 -2
- package/dist/test/test-helpers.d.mts.map +1 -1
- package/dist/test/test-helpers.mjs +35 -0
- package/dist/test/test-helpers.mjs.map +1 -1
- package/package.json +6 -6
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/bootstrap/node-bootstrap.mts +7 -21
- package/src/bootstrap/node-bootstrap.respec.mts +2 -2
- package/src/cli/cli-arg-parser.respec.mts +2 -2
- package/src/cli/cli-e2e.respec.mts +12 -12
- package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
- package/src/cli/commands/cli-add-cmd.mts +65 -0
- package/src/cli/commands/cli-branch-cmd.mts +87 -0
- package/src/cli/commands/cli-checkout-cmd.mts +72 -0
- package/src/cli/commands/cli-commit-cmd.mts +77 -0
- package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +12 -6
- package/src/cli/commands/cli-init-cmd.mts +78 -0
- package/src/cli/commands/cli-log-cmd.mts +126 -0
- package/src/cli/commands/cli-merge-cmd.mts +99 -0
- package/src/cli/commands/cli-reset-cmd.mts +94 -0
- package/src/cli/commands/cli-restore-cmd.mts +87 -0
- package/src/cli/commands/cli-status-cmd.mts +131 -0
- package/src/cli/commands/commit-log-cmd.respec.mts +85 -28
- package/src/cli/commands/init-cmd.respec.mts +3 -3
- package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
- package/src/cli/commands/status-add-cmd.respec.mts +21 -17
- package/src/cli/vcs-cli-main.mts +18 -15
- package/src/cli/vcs-projection-helper.mts +112 -0
- package/src/cli/vcs-repo-helper.mts +99 -0
- package/src/engine/branch/branch-space.respec.mts +23 -21
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +11 -11
- package/src/test/test-helpers.mts +50 -2
- package/src/vcs-gib.respec.mts +25 -16
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vcs-gib_test_output.md +58 -0
- package/dist/cli/commands/add-cmd.d.mts.map +0 -1
- package/dist/cli/commands/add-cmd.mjs +0 -346
- package/dist/cli/commands/add-cmd.mjs.map +0 -1
- package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
- package/dist/cli/commands/branch-cmd.mjs +0 -238
- package/dist/cli/commands/branch-cmd.mjs.map +0 -1
- package/dist/cli/commands/checkout-cmd.d.mts +0 -21
- package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
- package/dist/cli/commands/checkout-cmd.mjs +0 -174
- package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
- package/dist/cli/commands/commit-cmd.d.mts +0 -24
- package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
- package/dist/cli/commands/commit-cmd.mjs +0 -449
- package/dist/cli/commands/commit-cmd.mjs.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
- package/dist/cli/commands/init-cmd.d.mts.map +0 -1
- package/dist/cli/commands/init-cmd.mjs +0 -119
- package/dist/cli/commands/init-cmd.mjs.map +0 -1
- package/dist/cli/commands/log-cmd.d.mts.map +0 -1
- package/dist/cli/commands/log-cmd.mjs +0 -349
- package/dist/cli/commands/log-cmd.mjs.map +0 -1
- package/dist/cli/commands/merge-cmd.d.mts +0 -36
- package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
- package/dist/cli/commands/merge-cmd.mjs +0 -292
- package/dist/cli/commands/merge-cmd.mjs.map +0 -1
- package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
- package/dist/cli/commands/reset-cmd.mjs +0 -93
- package/dist/cli/commands/reset-cmd.mjs.map +0 -1
- package/dist/cli/commands/restore-cmd.d.mts +0 -22
- package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
- package/dist/cli/commands/restore-cmd.mjs +0 -115
- package/dist/cli/commands/restore-cmd.mjs.map +0 -1
- package/dist/cli/commands/status-cmd.d.mts.map +0 -1
- package/dist/cli/commands/status-cmd.mjs +0 -132
- package/dist/cli/commands/status-cmd.mjs.map +0 -1
- package/dist/engine/branch/branch-graph-helper.d.mts +0 -28
- package/dist/engine/branch/branch-graph-helper.d.mts.map +0 -1
- package/dist/engine/branch/branch-graph-helper.mjs +0 -81
- package/dist/engine/branch/branch-graph-helper.mjs.map +0 -1
- package/dist/engine/branch/branch-helper.d.mts +0 -40
- package/dist/engine/branch/branch-helper.d.mts.map +0 -1
- package/dist/engine/branch/branch-helper.mjs +0 -78
- package/dist/engine/branch/branch-helper.mjs.map +0 -1
- package/dist/engine/branch/branch-space-helper.d.mts +0 -23
- package/dist/engine/branch/branch-space-helper.d.mts.map +0 -1
- package/dist/engine/branch/branch-space-helper.mjs +0 -78
- package/dist/engine/branch/branch-space-helper.mjs.map +0 -1
- package/dist/engine/branch/branch-types.d.mts +0 -26
- package/dist/engine/branch/branch-types.d.mts.map +0 -1
- package/dist/engine/branch/branch-types.mjs +0 -7
- package/dist/engine/branch/branch-types.mjs.map +0 -1
- package/dist/engine/diff/line-diff-helper.d.mts +0 -76
- package/dist/engine/diff/line-diff-helper.d.mts.map +0 -1
- package/dist/engine/diff/line-diff-helper.mjs +0 -144
- package/dist/engine/diff/line-diff-helper.mjs.map +0 -1
- package/dist/engine/filter/glob-helper.d.mts +0 -51
- package/dist/engine/filter/glob-helper.d.mts.map +0 -1
- package/dist/engine/filter/glob-helper.mjs +0 -132
- package/dist/engine/filter/glob-helper.mjs.map +0 -1
- package/dist/engine/index/index-helper.d.mts +0 -113
- package/dist/engine/index/index-helper.d.mts.map +0 -1
- package/dist/engine/index/index-helper.mjs +0 -533
- package/dist/engine/index/index-helper.mjs.map +0 -1
- package/dist/engine/index/index-types.d.mts +0 -63
- package/dist/engine/index/index-types.d.mts.map +0 -1
- package/dist/engine/index/index-types.mjs +0 -7
- package/dist/engine/index/index-types.mjs.map +0 -1
- package/dist/engine/item/item-atom-helper.d.mts +0 -20
- package/dist/engine/item/item-atom-helper.d.mts.map +0 -1
- package/dist/engine/item/item-atom-helper.mjs +0 -30
- package/dist/engine/item/item-atom-helper.mjs.map +0 -1
- package/dist/engine/item/item-helper.d.mts +0 -94
- package/dist/engine/item/item-helper.d.mts.map +0 -1
- package/dist/engine/item/item-helper.mjs +0 -424
- package/dist/engine/item/item-helper.mjs.map +0 -1
- package/dist/engine/item/item-types.d.mts +0 -128
- package/dist/engine/item/item-types.d.mts.map +0 -1
- package/dist/engine/item/item-types.mjs +0 -16
- package/dist/engine/item/item-types.mjs.map +0 -1
- package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts +0 -74
- package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts.map +0 -1
- package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs +0 -570
- package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs.map +0 -1
- package/dist/engine/merge/b2tfs-3way-graft-types.d.mts +0 -34
- package/dist/engine/merge/b2tfs-3way-graft-types.d.mts.map +0 -1
- package/dist/engine/merge/b2tfs-3way-graft-types.mjs +0 -2
- package/dist/engine/merge/b2tfs-3way-graft-types.mjs.map +0 -1
- package/dist/engine/status/status-helper.d.mts +0 -90
- package/dist/engine/status/status-helper.d.mts.map +0 -1
- package/dist/engine/status/status-helper.mjs +0 -286
- package/dist/engine/status/status-helper.mjs.map +0 -1
- package/src/cli/commands/add-cmd.mts +0 -435
- package/src/cli/commands/branch-cmd.mts +0 -311
- package/src/cli/commands/checkout-cmd.mts +0 -227
- package/src/cli/commands/commit-cmd.mts +0 -557
- package/src/cli/commands/init-cmd.mts +0 -152
- package/src/cli/commands/log-cmd.mts +0 -449
- package/src/cli/commands/merge-cmd.mts +0 -363
- package/src/cli/commands/reset-cmd.mts +0 -128
- package/src/cli/commands/restore-cmd.mts +0 -155
- package/src/cli/commands/status-cmd.mts +0 -168
- package/src/engine/branch/branch-graph-helper.mts +0 -117
- package/src/engine/branch/branch-helper.mts +0 -112
- package/src/engine/branch/branch-space-helper.mts +0 -110
- package/src/engine/branch/branch-types.mts +0 -29
- package/src/engine/diff/line-diff-helper.mts +0 -210
- package/src/engine/diff/line-diff-helper.respec.mts +0 -84
- package/src/engine/filter/glob-helper.mts +0 -165
- package/src/engine/filter/glob-helper.respec.mts +0 -94
- package/src/engine/index/index-helper.mts +0 -705
- package/src/engine/index/index-types.mts +0 -66
- package/src/engine/item/item-atom-helper.mts +0 -30
- package/src/engine/item/item-helper.mts +0 -544
- package/src/engine/item/item-types.mts +0 -137
- package/src/engine/item/item.respec.mts +0 -92
- package/src/engine/merge/b2tfs-3way-graft-strategy.mts +0 -630
- package/src/engine/merge/b2tfs-3way-graft-strategy.respec.mts +0 -346
- package/src/engine/merge/b2tfs-3way-graft-types.mts +0 -34
- package/src/engine/status/status-helper.mts +0 -383
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module b2tfs-3way-graft-strategy.respec.node
|
|
3
|
-
*
|
|
4
|
-
* In-memory respec unit tests for B2tFS3WayGraftStrategy.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
respecfully, ifWe, iReckon,
|
|
9
|
-
firstOfEach
|
|
10
|
-
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
|
-
|
|
12
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
13
|
-
import { getGib } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
|
|
14
|
-
import { hash } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
15
|
-
import { InnerSpace_V1 } from '@ibgib/core-gib/dist/witness/space/inner-space/inner-space-v1.mjs';
|
|
16
|
-
import { DEFAULT_INNER_SPACE_DATA_V1 } from '@ibgib/core-gib/dist/witness/space/inner-space/inner-space-types.mjs';
|
|
17
|
-
import { persistTransformResult, registerNewIbGib, getFromSpace, putInSpace } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
18
|
-
import { SyncConflictStrategy } from '@ibgib/core-gib/dist/sync/sync-constants.mjs';
|
|
19
|
-
import { GraftPreference } from '@ibgib/core-gib/dist/sync/graft-info/graft-info-types.mjs';
|
|
20
|
-
import { getBinIb } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
21
|
-
import { BinIbGib_V1 } from '@ibgib/core-gib/dist/common/bin/bin-types.mjs';
|
|
22
|
-
import { GraftStrategyService } from '@ibgib/core-gib/dist/sync/graft-info/graft-strategy-service.mjs';
|
|
23
|
-
|
|
24
|
-
import { createB2tFSItemIbGib, evolveB2tFSItemIbGib } from '../item/item-helper.mjs';
|
|
25
|
-
import { B2tFSItemIbGib_V1, BINARY_REL8N_NAME } from '../item/item-types.mjs';
|
|
26
|
-
import { B2tFS3WayGraftStrategy } from './b2tfs-3way-graft-strategy.mjs';
|
|
27
|
-
|
|
28
|
-
const lc = `[apps/vcs-gib/src/engine/merge/b2tfs-3way-graft-strategy.respec.node.mts]`;
|
|
29
|
-
|
|
30
|
-
const graftStrategySvc = GraftStrategyService.instance;
|
|
31
|
-
|
|
32
|
-
function binDataToText(data: any): string {
|
|
33
|
-
if (!data) { return ''; }
|
|
34
|
-
if (typeof data === 'string') { return data; }
|
|
35
|
-
if (typeof data.text === 'string') { return data.text; }
|
|
36
|
-
if (typeof data.data === 'string') { return data.data; }
|
|
37
|
-
if (data instanceof Uint8Array || Buffer.isBuffer(data)) {
|
|
38
|
-
return new TextDecoder('utf8').decode(data);
|
|
39
|
-
}
|
|
40
|
-
if (typeof data === 'object') {
|
|
41
|
-
const vals = Object.values(data);
|
|
42
|
-
const bytes = new Uint8Array(vals as number[]);
|
|
43
|
-
return new TextDecoder('utf8').decode(bytes);
|
|
44
|
-
}
|
|
45
|
-
return String(data);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function createFileWithContent({
|
|
49
|
-
name,
|
|
50
|
-
content,
|
|
51
|
-
space,
|
|
52
|
-
}: {
|
|
53
|
-
name: string;
|
|
54
|
-
content: string | Uint8Array;
|
|
55
|
-
space: any;
|
|
56
|
-
}): Promise<B2tFSItemIbGib_V1> {
|
|
57
|
-
const textStr = typeof content === 'string' ? content : new TextDecoder('utf8').decode(content);
|
|
58
|
-
const dataBuffer = typeof content === 'string' ? Buffer.from(content, 'utf8') : content;
|
|
59
|
-
const fileHash = await hash({ s: textStr });
|
|
60
|
-
|
|
61
|
-
const fileExt = name.includes('.') ? name.split('.').pop() || 'txt' : 'txt';
|
|
62
|
-
const binIb = getBinIb({
|
|
63
|
-
binHash: fileHash,
|
|
64
|
-
binExt: fileExt,
|
|
65
|
-
binEncoding: 'utf8',
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const binIbGib: BinIbGib_V1 = {
|
|
69
|
-
ib: binIb,
|
|
70
|
-
data: dataBuffer,
|
|
71
|
-
};
|
|
72
|
-
binIbGib.gib = await getGib({ ibGib: binIbGib, hasTjp: false });
|
|
73
|
-
const binAddr = getIbGibAddr({ ibGib: binIbGib });
|
|
74
|
-
|
|
75
|
-
await putInSpace({ ibGib: binIbGib, space });
|
|
76
|
-
await registerNewIbGib({ ibGib: binIbGib, space });
|
|
77
|
-
|
|
78
|
-
const itemRes = await createB2tFSItemIbGib({
|
|
79
|
-
fsType: 'file',
|
|
80
|
-
name,
|
|
81
|
-
rel8ns: {
|
|
82
|
-
[BINARY_REL8N_NAME]: [binAddr],
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
await persistTransformResult({ resTransform: itemRes, space });
|
|
87
|
-
await registerNewIbGib({ ibGib: itemRes.newIbGib, space });
|
|
88
|
-
|
|
89
|
-
return itemRes.newIbGib as B2tFSItemIbGib_V1;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function evolveFileContent({
|
|
93
|
-
existingItem,
|
|
94
|
-
newContent,
|
|
95
|
-
space,
|
|
96
|
-
}: {
|
|
97
|
-
existingItem: B2tFSItemIbGib_V1;
|
|
98
|
-
newContent: string | Uint8Array;
|
|
99
|
-
space: any;
|
|
100
|
-
}): Promise<B2tFSItemIbGib_V1> {
|
|
101
|
-
const textStr = typeof newContent === 'string' ? newContent : new TextDecoder('utf8').decode(newContent);
|
|
102
|
-
const dataBuffer = typeof newContent === 'string' ? Buffer.from(newContent, 'utf8') : newContent;
|
|
103
|
-
const fileHash = await hash({ s: textStr });
|
|
104
|
-
|
|
105
|
-
const fileExt = existingItem.data?.fileExt || (existingItem.data?.name?.includes('.') ? existingItem.data.name.split('.').pop() || 'txt' : 'txt');
|
|
106
|
-
const binIb = getBinIb({
|
|
107
|
-
binHash: fileHash,
|
|
108
|
-
binExt: fileExt,
|
|
109
|
-
binEncoding: 'utf8',
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
const binIbGib: BinIbGib_V1 = {
|
|
113
|
-
ib: binIb,
|
|
114
|
-
data: dataBuffer,
|
|
115
|
-
};
|
|
116
|
-
binIbGib.gib = await getGib({ ibGib: binIbGib, hasTjp: false });
|
|
117
|
-
const binAddr = getIbGibAddr({ ibGib: binIbGib });
|
|
118
|
-
|
|
119
|
-
await putInSpace({ ibGib: binIbGib, space });
|
|
120
|
-
await registerNewIbGib({ ibGib: binIbGib, space });
|
|
121
|
-
|
|
122
|
-
const evolveRes = await evolveB2tFSItemIbGib({
|
|
123
|
-
existingItem,
|
|
124
|
-
rel8nsToUpdate: {
|
|
125
|
-
[BINARY_REL8N_NAME]: [binAddr],
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
await persistTransformResult({ resTransform: evolveRes, space });
|
|
130
|
-
await registerNewIbGib({ ibGib: evolveRes.newIbGib, space });
|
|
131
|
-
|
|
132
|
-
return evolveRes.newIbGib as B2tFSItemIbGib_V1;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
await respecfully(lc, `B2tFS3WayGraftStrategy In-Memory Respecs`, async () => {
|
|
136
|
-
|
|
137
|
-
firstOfEach(lc, async () => {
|
|
138
|
-
graftStrategySvc.reset();
|
|
139
|
-
graftStrategySvc.registerStrategy(new B2tFS3WayGraftStrategy());
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
await ifWe(lc, `performs non-conflicting line merges across two branch timelines`, async () => {
|
|
143
|
-
const space = new InnerSpace_V1({
|
|
144
|
-
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
145
|
-
name: 'test_space_1',
|
|
146
|
-
uuid: 'test_space_uuid_1',
|
|
147
|
-
});
|
|
148
|
-
await space.initialized;
|
|
149
|
-
|
|
150
|
-
const initialText = "line 1\nline 2\nline 3";
|
|
151
|
-
const lcaFile = await createFileWithContent({ name: 'app.ts', content: initialText, space });
|
|
152
|
-
const lcaAddr = getIbGibAddr({ ibGib: lcaFile });
|
|
153
|
-
|
|
154
|
-
// Base branch modifies line 1
|
|
155
|
-
const baseText = "line 1 modified by base\nline 2\nline 3";
|
|
156
|
-
const baseFile = await evolveFileContent({ existingItem: lcaFile, newContent: baseText, space });
|
|
157
|
-
const baseFileAddr = getIbGibAddr({ ibGib: baseFile });
|
|
158
|
-
|
|
159
|
-
// Orphan branch modifies line 3
|
|
160
|
-
const orphanText = "line 1\nline 2\nline 3 modified by orphan";
|
|
161
|
-
const orphanFile = await evolveFileContent({ existingItem: lcaFile, newContent: orphanText, space });
|
|
162
|
-
const orphanFileAddr = getIbGibAddr({ ibGib: orphanFile });
|
|
163
|
-
|
|
164
|
-
const timelineA = [lcaAddr, baseFileAddr];
|
|
165
|
-
const timelineB = [lcaAddr, orphanFileAddr];
|
|
166
|
-
|
|
167
|
-
const graftResult = await graftStrategySvc.graftTimelines({
|
|
168
|
-
timelineAddrsA: timelineA,
|
|
169
|
-
timelineAddrsB: timelineB,
|
|
170
|
-
latestCommonFrameAddr: lcaAddr,
|
|
171
|
-
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
172
|
-
ibGibReadCache: {},
|
|
173
|
-
space,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
iReckon(lc, graftResult.newGraftTip).isGonnaBeTruthy();
|
|
177
|
-
|
|
178
|
-
const tipGet = await getFromSpace({ space, addrs: [getIbGibAddr({ ibGib: graftResult.newGraftTip })] });
|
|
179
|
-
const mergedFile = tipGet.ibGibs![0] as B2tFSItemIbGib_V1;
|
|
180
|
-
|
|
181
|
-
const binAddr = mergedFile.rel8ns?.[BINARY_REL8N_NAME]?.at(-1);
|
|
182
|
-
iReckon(lc, binAddr).isGonnaBeTruthy();
|
|
183
|
-
|
|
184
|
-
const binGet = await getFromSpace({ space, addrs: [binAddr!] });
|
|
185
|
-
const binIbGib = binGet.ibGibs![0];
|
|
186
|
-
|
|
187
|
-
const text = binDataToText(binIbGib.data);
|
|
188
|
-
iReckon(lc, text).includes('line 1 modified by base');
|
|
189
|
-
iReckon(lc, text).includes('line 2');
|
|
190
|
-
iReckon(lc, text).includes('line 3 modified by orphan');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
await ifWe(lc, `inserts Git conflict markers on conflicting text line merges`, async () => {
|
|
194
|
-
const space = new InnerSpace_V1({
|
|
195
|
-
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
196
|
-
name: 'test_space_2',
|
|
197
|
-
uuid: 'test_space_uuid_2',
|
|
198
|
-
});
|
|
199
|
-
await space.initialized;
|
|
200
|
-
|
|
201
|
-
const initialText = "line 1\nline 2\nline 3";
|
|
202
|
-
const lcaFile = await createFileWithContent({ name: 'index.ts', content: initialText, space });
|
|
203
|
-
const lcaAddr = getIbGibAddr({ ibGib: lcaFile });
|
|
204
|
-
|
|
205
|
-
// Base modifies line 2
|
|
206
|
-
const baseText = "line 1\nline 2 base edit\nline 3";
|
|
207
|
-
const baseFile = await evolveFileContent({ existingItem: lcaFile, newContent: baseText, space });
|
|
208
|
-
const baseFileAddr = getIbGibAddr({ ibGib: baseFile });
|
|
209
|
-
|
|
210
|
-
// Orphan modifies line 2 differently
|
|
211
|
-
const orphanText = "line 1\nline 2 orphan edit\nline 3";
|
|
212
|
-
const orphanFile = await evolveFileContent({ existingItem: lcaFile, newContent: orphanText, space });
|
|
213
|
-
const orphanFileAddr = getIbGibAddr({ ibGib: orphanFile });
|
|
214
|
-
|
|
215
|
-
const timelineA = [lcaAddr, baseFileAddr];
|
|
216
|
-
const timelineB = [lcaAddr, orphanFileAddr];
|
|
217
|
-
|
|
218
|
-
const graftResult = await graftStrategySvc.graftTimelines({
|
|
219
|
-
timelineAddrsA: timelineA,
|
|
220
|
-
timelineAddrsB: timelineB,
|
|
221
|
-
latestCommonFrameAddr: lcaAddr,
|
|
222
|
-
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
223
|
-
ibGibReadCache: {},
|
|
224
|
-
space,
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
const tipGet = await getFromSpace({ space, addrs: [getIbGibAddr({ ibGib: graftResult.newGraftTip })] });
|
|
228
|
-
const mergedFile = tipGet.ibGibs![0] as B2tFSItemIbGib_V1;
|
|
229
|
-
|
|
230
|
-
const binAddr = mergedFile.rel8ns?.[BINARY_REL8N_NAME]?.at(-1);
|
|
231
|
-
const binGet = await getFromSpace({ space, addrs: [binAddr!] });
|
|
232
|
-
const binIbGib = binGet.ibGibs![0];
|
|
233
|
-
|
|
234
|
-
const text = binDataToText(binIbGib.data);
|
|
235
|
-
iReckon(lc, text).includes('<<<<<<< HEAD');
|
|
236
|
-
iReckon(lc, text).includes('line 2 base edit');
|
|
237
|
-
iReckon(lc, text).includes('=======');
|
|
238
|
-
iReckon(lc, text).includes('line 2 orphan edit');
|
|
239
|
-
iReckon(lc, text).includes('>>>>>>>');
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
await ifWe(lc, `skips line diff merging for non-text binary files`, async () => {
|
|
243
|
-
const space = new InnerSpace_V1({
|
|
244
|
-
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
245
|
-
name: 'test_space_3',
|
|
246
|
-
uuid: 'test_space_uuid_3',
|
|
247
|
-
});
|
|
248
|
-
await space.initialized;
|
|
249
|
-
|
|
250
|
-
const lcaBinData = new Uint8Array([0x00, 0x01, 0x02, 0x03]);
|
|
251
|
-
const lcaFile = await createFileWithContent({ name: 'image.png', content: lcaBinData, space });
|
|
252
|
-
const lcaAddr = getIbGibAddr({ ibGib: lcaFile });
|
|
253
|
-
|
|
254
|
-
const baseBinData = new Uint8Array([0x00, 0x01, 0x02, 0x04]);
|
|
255
|
-
const baseFile = await evolveFileContent({ existingItem: lcaFile, newContent: baseBinData, space });
|
|
256
|
-
const baseFileAddr = getIbGibAddr({ ibGib: baseFile });
|
|
257
|
-
|
|
258
|
-
const orphanBinData = new Uint8Array([0x00, 0x01, 0x02, 0x05]);
|
|
259
|
-
const orphanFile = await evolveFileContent({ existingItem: lcaFile, newContent: orphanBinData, space });
|
|
260
|
-
const orphanFileAddr = getIbGibAddr({ ibGib: orphanFile });
|
|
261
|
-
|
|
262
|
-
const timelineA = [lcaAddr, baseFileAddr];
|
|
263
|
-
const timelineB = [lcaAddr, orphanFileAddr];
|
|
264
|
-
|
|
265
|
-
const graftResult = await graftStrategySvc.graftTimelines({
|
|
266
|
-
timelineAddrsA: timelineA,
|
|
267
|
-
timelineAddrsB: timelineB,
|
|
268
|
-
latestCommonFrameAddr: lcaAddr,
|
|
269
|
-
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
270
|
-
ibGibReadCache: {},
|
|
271
|
-
space,
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
iReckon(lc, graftResult.newGraftTip).isGonnaBeTruthy();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
await ifWe(lc, `respects GraftPreference.receiver by using timelineB (receiver) as baseTip`, async () => {
|
|
278
|
-
const space = new InnerSpace_V1({
|
|
279
|
-
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
280
|
-
name: 'test_space_4',
|
|
281
|
-
uuid: 'test_space_uuid_4',
|
|
282
|
-
});
|
|
283
|
-
await space.initialized;
|
|
284
|
-
|
|
285
|
-
const initialText = "base content";
|
|
286
|
-
const lcaFile = await createFileWithContent({ name: 'file.txt', content: initialText, space });
|
|
287
|
-
const lcaAddr = getIbGibAddr({ ibGib: lcaFile });
|
|
288
|
-
|
|
289
|
-
const baseFile = await evolveFileContent({ existingItem: lcaFile, newContent: "base edit", space });
|
|
290
|
-
const baseFileAddr = getIbGibAddr({ ibGib: baseFile });
|
|
291
|
-
|
|
292
|
-
const orphanFile = await evolveFileContent({ existingItem: lcaFile, newContent: "orphan edit", space });
|
|
293
|
-
const orphanFileAddr = getIbGibAddr({ ibGib: orphanFile });
|
|
294
|
-
|
|
295
|
-
const timelineA_sender = [lcaAddr, baseFileAddr];
|
|
296
|
-
const timelineB_receiver = [lcaAddr, orphanFileAddr];
|
|
297
|
-
|
|
298
|
-
const graftResult = await graftStrategySvc.graftTimelines({
|
|
299
|
-
timelineAddrsA: timelineA_sender,
|
|
300
|
-
timelineAddrsB: timelineB_receiver,
|
|
301
|
-
latestCommonFrameAddr: lcaAddr,
|
|
302
|
-
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
303
|
-
ibGibReadCache: {},
|
|
304
|
-
space,
|
|
305
|
-
graftPreference: GraftPreference.receiver,
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
iReckon(lc, graftResult.newGraftTip).isGonnaBeTruthy();
|
|
309
|
-
iReckon(lc, graftResult.newGraftTip.rel8ns?.past).includes(orphanFileAddr);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
await ifWe(lc, `respects GraftPreference.sender by using timelineA (sender) as baseTip`, async () => {
|
|
313
|
-
const space = new InnerSpace_V1({
|
|
314
|
-
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
315
|
-
name: 'test_space_5',
|
|
316
|
-
uuid: 'test_space_uuid_5',
|
|
317
|
-
});
|
|
318
|
-
await space.initialized;
|
|
319
|
-
|
|
320
|
-
const initialText = "base content";
|
|
321
|
-
const lcaFile = await createFileWithContent({ name: 'file.txt', content: initialText, space });
|
|
322
|
-
const lcaAddr = getIbGibAddr({ ibGib: lcaFile });
|
|
323
|
-
|
|
324
|
-
const baseFile = await evolveFileContent({ existingItem: lcaFile, newContent: "sender edit", space });
|
|
325
|
-
const baseFileAddr = getIbGibAddr({ ibGib: baseFile });
|
|
326
|
-
|
|
327
|
-
const orphanFile = await evolveFileContent({ existingItem: lcaFile, newContent: "receiver edit", space });
|
|
328
|
-
const orphanFileAddr = getIbGibAddr({ ibGib: orphanFile });
|
|
329
|
-
|
|
330
|
-
const timelineA_sender = [lcaAddr, baseFileAddr];
|
|
331
|
-
const timelineB_receiver = [lcaAddr, orphanFileAddr];
|
|
332
|
-
|
|
333
|
-
const graftResult = await graftStrategySvc.graftTimelines({
|
|
334
|
-
timelineAddrsA: timelineA_sender,
|
|
335
|
-
timelineAddrsB: timelineB_receiver,
|
|
336
|
-
latestCommonFrameAddr: lcaAddr,
|
|
337
|
-
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
338
|
-
ibGibReadCache: {},
|
|
339
|
-
space,
|
|
340
|
-
graftPreference: GraftPreference.sender,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
iReckon(lc, graftResult.newGraftTip).isGonnaBeTruthy();
|
|
344
|
-
iReckon(lc, graftResult.newGraftTip.rel8ns?.past).includes(baseFileAddr);
|
|
345
|
-
});
|
|
346
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
2
|
-
import { AddlGraftDetails } from "@ibgib/core-gib/dist/sync/graft-info/graft-info-types.mjs";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Contains references to key b2tfs item ibgibs and their corresponding binary ibgibs.
|
|
6
|
-
*/
|
|
7
|
-
export interface B2tFS3WayAddlGraftDetails extends AddlGraftDetails {
|
|
8
|
-
/**
|
|
9
|
-
* So if merging `my-feature-branch` into `main`...
|
|
10
|
-
*
|
|
11
|
-
* this is the b2tfs item that points to the binary ibgib with text of the
|
|
12
|
-
* file in `main`
|
|
13
|
-
*/
|
|
14
|
-
baseTextB2tFSItemAddr: IbGibAddr;
|
|
15
|
-
/**
|
|
16
|
-
* So if merging `my-feature-branch` into `main`...
|
|
17
|
-
*
|
|
18
|
-
* this is the binary ibgib whose text is in `main`
|
|
19
|
-
*/
|
|
20
|
-
baseTextBinAddr: IbGibAddr | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* So if merging `my-feature-branch` into `main`...
|
|
23
|
-
*
|
|
24
|
-
* this is the b2tfs item that points to the binary ibgib with text of the
|
|
25
|
-
* file in `my-feature-branch`
|
|
26
|
-
*/
|
|
27
|
-
orphanTextB2tFSItemAddr: IbGibAddr;
|
|
28
|
-
/**
|
|
29
|
-
* So if merging `my-feature-branch` into `main`...
|
|
30
|
-
*
|
|
31
|
-
* this is the binary ibgib whose text is in `my-feature-branch`
|
|
32
|
-
*/
|
|
33
|
-
orphanTextBinAddr: IbGibAddr | undefined;
|
|
34
|
-
}
|