@ibgib/vcs-gib 0.0.32 → 0.0.34
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/README.md +14 -7
- 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 +6 -20
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +1 -1
- 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} +1 -1
- 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/{checkout-cmd.d.mts → cli-checkout-cmd.d.mts} +4 -3
- 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/{commit-cmd.d.mts → cli-commit-cmd.d.mts} +1 -1
- 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} +8 -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} +1 -1
- 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} +1 -1
- package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{log-cmd.mjs → cli-log-cmd.mjs} +14 -44
- package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
- package/dist/cli/commands/{merge-cmd.d.mts → cli-merge-cmd.d.mts} +1 -1
- 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} +1 -1
- 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/{restore-cmd.d.mts → cli-restore-cmd.d.mts} +1 -1
- 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} +1 -1
- package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{status-cmd.mjs → cli-status-cmd.mjs} +4 -41
- 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.mjs +7 -7
- package/dist/cli/vcs-projection-helper.mjs.map +1 -1
- 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 +84 -0
- package/dist/cli/vcs-repo-helper.mjs.map +1 -0
- package/dist/test/test-helpers.d.mts +9 -0
- 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 +6 -20
- 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 +15 -14
- package/src/cli/commands/branch-checkout-cmd.respec.mts +28 -14
- 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} +8 -6
- package/src/cli/commands/cli-init-cmd.mts +78 -0
- package/src/cli/commands/{log-cmd.mts → cli-log-cmd.mts} +14 -47
- 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/{status-cmd.mts → cli-status-cmd.mts} +3 -45
- package/src/cli/commands/commit-log-cmd.respec.mts +84 -34
- 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 +13 -9
- package/src/cli/vcs-cli-main.mts +18 -15
- package/src/cli/vcs-projection-helper.mts +8 -8
- package/src/cli/vcs-repo-helper.mts +113 -0
- package/src/engine/branch/branch-space.respec.mts +22 -20
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +10 -10
- package/src/test/test-helpers.mts +49 -1
- package/src/vcs-gib.respec.mts +21 -15
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vcs-gib_test_output.md +77 -0
- package/dist/cli/commands/add-cmd.d.mts.map +0 -1
- package/dist/cli/commands/add-cmd.mjs +0 -93
- 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 -107
- package/dist/cli/commands/branch-cmd.mjs.map +0 -1
- package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
- package/dist/cli/commands/checkout-cmd.mjs +0 -95
- package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
- package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
- package/dist/cli/commands/commit-cmd.mjs +0 -99
- 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 -69
- 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.map +0 -1
- package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
- package/dist/cli/commands/merge-cmd.mjs +0 -106
- 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 -91
- package/dist/cli/commands/reset-cmd.mjs.map +0 -1
- package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
- package/dist/cli/commands/restore-cmd.mjs +0 -97
- 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.map +0 -1
- package/src/cli/commands/add-cmd.mts +0 -120
- package/src/cli/commands/branch-cmd.mts +0 -142
- package/src/cli/commands/checkout-cmd.mts +0 -123
- package/src/cli/commands/commit-cmd.mts +0 -130
- package/src/cli/commands/init-cmd.mts +0 -99
- package/src/cli/commands/merge-cmd.mts +0 -143
- package/src/cli/commands/reset-cmd.mts +0 -126
- package/src/cli/commands/restore-cmd.mts +0 -135
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module vcs-repo-helper
|
|
3
|
+
*
|
|
4
|
+
* Helper to bootstrap Node environment and open a VcsRepository session.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
|
+
|
|
10
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
11
|
+
import { VcsRepository, WorkspaceProjectionSpaceFactory } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
|
|
12
|
+
import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
13
|
+
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
14
|
+
import { getOrCreateBranchSpace } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
15
|
+
import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
|
|
16
|
+
|
|
17
|
+
import { GLOBAL_LOG_A_LOT } from '../vcs-gib-constants.mjs';
|
|
18
|
+
import { bootstrapVcsMetaspace } from '../bootstrap/node-bootstrap.mjs';
|
|
19
|
+
import { B2TFS_BRANCH_DEFAULT_NAME } from '@ibgib/core-gib/dist/vcs/branch/branch-constants.mjs';
|
|
20
|
+
|
|
21
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
22
|
+
|
|
23
|
+
export interface OpenVcsRepositoryOpts {
|
|
24
|
+
targetDir?: string;
|
|
25
|
+
vcsFolderName?: string;
|
|
26
|
+
branchName?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface OpenVcsRepositoryResult {
|
|
30
|
+
repo: VcsRepository;
|
|
31
|
+
repoRoot: string;
|
|
32
|
+
vcsPath: string;
|
|
33
|
+
activeWorktreeDir: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function openVcsRepository({
|
|
37
|
+
targetDir = process.cwd(),
|
|
38
|
+
vcsFolderName = '.vcsgib',
|
|
39
|
+
branchName,
|
|
40
|
+
}: OpenVcsRepositoryOpts = {}): Promise<OpenVcsRepositoryResult> {
|
|
41
|
+
const lc = `[${openVcsRepository.name}]`;
|
|
42
|
+
try {
|
|
43
|
+
if (logalot) { console.log(`${lc} starting... (I: 4a621eb5576a3064f85177c6de80a826)`); }
|
|
44
|
+
|
|
45
|
+
const absTargetDir = path.resolve(targetDir);
|
|
46
|
+
|
|
47
|
+
// 1. Locate repository root and bootstrap Node localSpace
|
|
48
|
+
const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
|
|
49
|
+
repoPath: absTargetDir,
|
|
50
|
+
vcsFolderName,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// 2. Fetch authoritative in-band index from localSpace
|
|
54
|
+
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
|
|
55
|
+
if (!indexIbGib) {
|
|
56
|
+
throw new Error(`Not an ibgib repository (index not found in ${vcsPath})`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 3. Determine active branch and worktree directory
|
|
60
|
+
const activeBranchName = branchName || resolveContextualBranchName({
|
|
61
|
+
targetDir: absTargetDir,
|
|
62
|
+
repoRoot,
|
|
63
|
+
indexIbGib,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const activeWorktreeDir = activeBranchName === B2TFS_BRANCH_DEFAULT_NAME
|
|
67
|
+
? repoRoot
|
|
68
|
+
: path.join(repoRoot, 'b', activeBranchName);
|
|
69
|
+
|
|
70
|
+
// 4. Resolve branch space & create Node workspace projection space
|
|
71
|
+
const { space: activeSpace } = await getOrCreateBranchSpace({
|
|
72
|
+
metaspace,
|
|
73
|
+
branchName: activeBranchName,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
|
|
77
|
+
metaspace,
|
|
78
|
+
workspaceRoot: activeWorktreeDir,
|
|
79
|
+
vcsFolderName,
|
|
80
|
+
backingSpace: activeSpace,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const fnGetWorkspaceProjectionSpace: WorkspaceProjectionSpaceFactory = async ({
|
|
84
|
+
worktreeDir,
|
|
85
|
+
backingSpace,
|
|
86
|
+
}) => {
|
|
87
|
+
const { space } = await getOrCreateWorkspaceProjectionSpace({
|
|
88
|
+
metaspace,
|
|
89
|
+
workspaceRoot: worktreeDir,
|
|
90
|
+
vcsFolderName,
|
|
91
|
+
backingSpace,
|
|
92
|
+
});
|
|
93
|
+
return space;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// 5. Construct domain facade
|
|
97
|
+
const repo = new VcsRepository({
|
|
98
|
+
metaspace,
|
|
99
|
+
localSpace,
|
|
100
|
+
workspaceSpace,
|
|
101
|
+
fnGetWorkspaceProjectionSpace,
|
|
102
|
+
repoRoot,
|
|
103
|
+
vcsFolderName,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return { repo, repoRoot, activeWorktreeDir, vcsPath };
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
109
|
+
throw error;
|
|
110
|
+
} finally {
|
|
111
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module branch-space.respec.node
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Unit tests for branch space helper, space-qualified address formatting/parsing,
|
|
5
5
|
* and graph population into branch spaces.
|
|
6
6
|
*/
|
|
@@ -8,44 +8,49 @@
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import fs from 'node:fs/promises';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
11
|
+
import { respecfully, ifWe, iReckon } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
12
|
+
|
|
14
13
|
import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
15
14
|
import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
16
15
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
17
16
|
import { getFromSpace, persistTransformResult } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
18
|
-
|
|
19
|
-
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
20
17
|
import { getB2tFSItemIb } from '@ibgib/core-gib/dist/vcs/item/item-atom-helper.mjs';
|
|
21
|
-
import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
|
|
22
18
|
import { populateBranchSpaceFromGraph } from '@ibgib/core-gib/dist/vcs/branch/branch-graph-helper.mjs';
|
|
23
|
-
import { getSpaceQualifiedIbGibAddr, parseSpaceQualifiedIbGibAddr } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
24
19
|
import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
20
|
+
import { getOrCreateBranchSpace } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
21
|
+
import { getSpaceQualifiedIbGibAddr, parseSpaceQualifiedIbGibAddr, isSpaceQualifiedAddr } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
24
|
+
|
|
25
|
+
const lc = `[apps/vcs-gib/src/engine/branch/branch-space.respec.mts]`;
|
|
27
26
|
|
|
28
27
|
await respecfully(lc, `Branch Space & Graph Helper Respecs`, async () => {
|
|
29
28
|
|
|
30
29
|
await respecfully(lc, `Space-Qualified Address Parsing & Formatting`, async () => {
|
|
31
30
|
await ifWe(lc, `formats space-qualified address using options object`, async () => {
|
|
32
|
-
const sq = getSpaceQualifiedIbGibAddr({ spaceId: 'sp_alpha', ibGibAddr: 'item_a^
|
|
33
|
-
iReckon(lc, sq).willEqual('v:1^spaceId:sp_alpha^item_a^
|
|
31
|
+
const sq = getSpaceQualifiedIbGibAddr({ spaceId: 'sp_alpha', ibGibAddr: 'item_a^gib' });
|
|
32
|
+
iReckon(lc, sq).willEqual('v:1^spaceId:sp_alpha^item_a^gib');
|
|
34
33
|
});
|
|
35
34
|
|
|
36
35
|
await ifWe(lc, `parses space-qualified address using options object`, async () => {
|
|
37
|
-
const parsed = parseSpaceQualifiedIbGibAddr({
|
|
36
|
+
const parsed = parseSpaceQualifiedIbGibAddr({ sqAddr: 'v:1^spaceId:sp_alpha^item_a^gib' });
|
|
38
37
|
iReckon(lc, parsed).isGonnaBeTruthy();
|
|
39
38
|
iReckon(lc, parsed!.version).willEqual(1);
|
|
40
39
|
iReckon(lc, parsed!.spaceId).willEqual('sp_alpha');
|
|
41
|
-
iReckon(lc, parsed!.ibGibAddr).willEqual('item_a^
|
|
40
|
+
iReckon(lc, parsed!.ibGibAddr).willEqual('item_a^gib');
|
|
42
41
|
iReckon(lc, parsed!.ib).willEqual('item_a');
|
|
43
|
-
iReckon(lc, parsed!.gib).willEqual('
|
|
42
|
+
iReckon(lc, parsed!.gib).willEqual('gib');
|
|
44
43
|
});
|
|
45
44
|
|
|
46
|
-
await ifWe(lc, `
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
await ifWe(lc, `throws for invalid space-qualified address string`, async () => {
|
|
46
|
+
let threw = false;
|
|
47
|
+
try {
|
|
48
|
+
parseSpaceQualifiedIbGibAddr({ sqAddr: 'invalid_address_string' });
|
|
49
|
+
} catch {
|
|
50
|
+
threw = true;
|
|
51
|
+
}
|
|
52
|
+
iReckon(lc, threw).isGonnaBeTrue();
|
|
53
|
+
iReckon(lc, isSpaceQualifiedAddr('invalid_address_string')).isGonnaBeFalse();
|
|
49
54
|
});
|
|
50
55
|
});
|
|
51
56
|
|
|
@@ -62,7 +67,6 @@ await respecfully(lc, `Branch Space & Graph Helper Respecs`, async () => {
|
|
|
62
67
|
const branchName = 'feature_alpha';
|
|
63
68
|
const result1 = await getOrCreateBranchSpace({
|
|
64
69
|
metaspace,
|
|
65
|
-
vcsPath,
|
|
66
70
|
branchName,
|
|
67
71
|
});
|
|
68
72
|
|
|
@@ -72,7 +76,6 @@ await respecfully(lc, `Branch Space & Graph Helper Respecs`, async () => {
|
|
|
72
76
|
|
|
73
77
|
const result2 = await getOrCreateBranchSpace({
|
|
74
78
|
metaspace,
|
|
75
|
-
vcsPath,
|
|
76
79
|
branchName,
|
|
77
80
|
});
|
|
78
81
|
|
|
@@ -132,7 +135,6 @@ await respecfully(lc, `Branch Space & Graph Helper Respecs`, async () => {
|
|
|
132
135
|
// Create target branch space
|
|
133
136
|
const { space: targetBranchSpace } = await getOrCreateBranchSpace({
|
|
134
137
|
metaspace,
|
|
135
|
-
vcsPath,
|
|
136
138
|
branchName: 'main',
|
|
137
139
|
});
|
|
138
140
|
|
|
@@ -25,14 +25,14 @@ import { createCommentIbGib } from '@ibgib/core-gib/dist/common/comment/comment-
|
|
|
25
25
|
import { getBinIb } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
26
26
|
import { BinIbGib_V1 } from '@ibgib/core-gib/dist/common/bin/bin-types.mjs';
|
|
27
27
|
import { putInSpace, persistTransformResult, registerNewIbGib, getFromSpace, getLatestAddrs } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
28
|
-
|
|
29
|
-
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
30
|
-
import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
|
|
31
28
|
import { createB2tFSItemIbGib, evolveB2tFSItemIbGib } from '@ibgib/core-gib/dist/vcs/item/item-helper.mjs';
|
|
32
29
|
import { B2tFSItemIbGib_V1, BINARY_REL8N_NAME } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
33
30
|
import { B2tFS3WayGraftStrategy } from '@ibgib/core-gib/dist/vcs/merge/b2tfs-3way-graft-strategy.mjs';
|
|
31
|
+
import { getOrCreateBranchSpace } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
32
|
+
|
|
33
|
+
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
34
34
|
|
|
35
|
-
const lc = `[apps/vcs-gib/src/engine/merge/b2tfs-sync-comments.respec.
|
|
35
|
+
const lc = `[apps/vcs-gib/src/engine/merge/b2tfs-sync-comments.respec.mts]`;
|
|
36
36
|
const graftStrategySvc = GraftStrategyService.instance;
|
|
37
37
|
|
|
38
38
|
async function createFileWithBinAndComment({
|
|
@@ -149,8 +149,8 @@ await respecfully(lc, `B2tFS Item & Comment Sync Graph Integrity`, async () => {
|
|
|
149
149
|
repoPath: testDir,
|
|
150
150
|
vcsFolderName,
|
|
151
151
|
});
|
|
152
|
-
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace,
|
|
153
|
-
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace,
|
|
152
|
+
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_a' });
|
|
153
|
+
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_b' });
|
|
154
154
|
|
|
155
155
|
// 1. Create file item with comment in Space A
|
|
156
156
|
const { fileItem } = await createFileWithBinAndComment({
|
|
@@ -208,8 +208,8 @@ await respecfully(lc, `B2tFS Item & Comment Sync Graph Integrity`, async () => {
|
|
|
208
208
|
repoPath: testDir,
|
|
209
209
|
vcsFolderName,
|
|
210
210
|
});
|
|
211
|
-
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace,
|
|
212
|
-
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace,
|
|
211
|
+
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_a' });
|
|
212
|
+
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_b' });
|
|
213
213
|
|
|
214
214
|
// 1. Create file with comment 1 in Space A
|
|
215
215
|
const { fileItem: fileItemA1 } = await createFileWithBinAndComment({
|
|
@@ -299,8 +299,8 @@ await respecfully(lc, `B2tFS Item & Comment Sync Graph Integrity`, async () => {
|
|
|
299
299
|
repoPath: testDir,
|
|
300
300
|
vcsFolderName,
|
|
301
301
|
});
|
|
302
|
-
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace,
|
|
303
|
-
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace,
|
|
302
|
+
const { space: spaceA } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_a' });
|
|
303
|
+
const { space: spaceB } = await getOrCreateBranchSpace({ metaspace, branchName: 'branch_b' });
|
|
304
304
|
|
|
305
305
|
// 1. Initial base file in Space A
|
|
306
306
|
const { fileItem: lcaFile } = await createFileWithBinAndComment({
|
|
@@ -21,7 +21,8 @@ import { getLatestAddrs } from '@ibgib/core-gib/dist/witness/space/space-helper.
|
|
|
21
21
|
import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
|
|
22
22
|
|
|
23
23
|
import { B2tFSBranchIbGib_V1 } from '@ibgib/core-gib/dist/vcs/branch/branch-types.mjs';
|
|
24
|
-
import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
24
|
+
import { B2tFSItemIbGib_V1, B2TFS_CHILD_ITEM_REL8N_NAME } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
25
|
+
import { getIbGibFromSpace } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -166,3 +167,50 @@ export function logAddr(label: string, addr: IbGibAddr | undefined): void {
|
|
|
166
167
|
export function logAddrs(label: string, addrs: IbGibAddr[] | undefined): void {
|
|
167
168
|
console.log(`[ADDRS][${label}]: ${shortAddrs(addrs)}`);
|
|
168
169
|
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Recursively logs the b2tfs item hierarchy from a rootItemAddr within a space.
|
|
173
|
+
*/
|
|
174
|
+
export async function logTreeHierarchy({
|
|
175
|
+
label,
|
|
176
|
+
rootItemAddr,
|
|
177
|
+
space,
|
|
178
|
+
metaspace,
|
|
179
|
+
}: {
|
|
180
|
+
label: string;
|
|
181
|
+
rootItemAddr?: string;
|
|
182
|
+
space: any;
|
|
183
|
+
metaspace?: any;
|
|
184
|
+
}): Promise<void> {
|
|
185
|
+
const lc = `[TRACE_B2TFS][${label}]`;
|
|
186
|
+
const spaceName = space?.data?.name || space?.data?.spaceSubPath || space?.ib || 'unknown';
|
|
187
|
+
console.log(`${lc} === Hierarchy for root: ${shortAddr(rootItemAddr)} in space: ${spaceName} ===`);
|
|
188
|
+
if (!rootItemAddr) {
|
|
189
|
+
console.log(`${lc} rootItemAddr is falsy`);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function walk(addr: string, depth: number, currentPath: string): Promise<void> {
|
|
194
|
+
const indent = ' '.repeat(depth);
|
|
195
|
+
const item = await getIbGibFromSpace({ addr, space, metaspace }) as B2tFSItemIbGib_V1;
|
|
196
|
+
if (!item) {
|
|
197
|
+
console.log(`${lc}${indent} ❌ MISSING item at ${shortAddr(addr)} (path: ${currentPath})`);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const name = item.data?.name || '(root)';
|
|
201
|
+
const fsType = item.data?.fsType || 'unknown';
|
|
202
|
+
const comments = item.rel8ns?.comment || [];
|
|
203
|
+
const children = item.rel8ns?.[B2TFS_CHILD_ITEM_REL8N_NAME] || [];
|
|
204
|
+
console.log(`${lc}${indent} 📁 ${name} (${fsType}) addr: ${shortAddr(addr)} comments: ${comments.length} children: ${children.length}`);
|
|
205
|
+
for (const cAddr of comments) {
|
|
206
|
+
const comment = await getIbGibFromSpace({ addr: cAddr, space, metaspace });
|
|
207
|
+
console.log(`${lc}${indent} 💬 comment: "${(comment?.data as any)?.text?.slice(0, 50)}"`);
|
|
208
|
+
}
|
|
209
|
+
for (const childAddr of children) {
|
|
210
|
+
await walk(childAddr, depth + 1, currentPath ? `${currentPath}/${name}` : name);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
await walk(rootItemAddr, 1, '');
|
|
215
|
+
}
|
|
216
|
+
|
package/src/vcs-gib.respec.mts
CHANGED
|
@@ -11,19 +11,17 @@ import fs from 'node:fs/promises';
|
|
|
11
11
|
import { respecfully, ifWe, iReckon } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
12
12
|
import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
13
13
|
import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
14
|
+
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
15
|
import { getB2tFSItemIb } from '@ibgib/core-gib/dist/vcs/item/item-atom-helper.mjs';
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
} from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
18
|
-
import {
|
|
19
|
-
createB2tFSIndexIbGib, getSpaceQualifiedIbGibAddr,
|
|
20
|
-
parseSpaceQualifiedIbGibAddr
|
|
21
|
-
} from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
16
|
+
import { createB2tFSBranchIbGib, getB2tFSBranchSpaceName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
17
|
+
import { createB2tFSIndexIbGib, } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
22
18
|
import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
19
|
+
import { getSpaceQualifiedIbGibAddr, parseSpaceQualifiedIbGibAddr } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
20
|
+
import { getSpaceIdFromIb } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-innerspace/metaspace-innerspace-helper.mjs';
|
|
23
21
|
|
|
24
22
|
import { bootstrapVcsMetaspace } from './bootstrap/node-bootstrap.mjs';
|
|
25
23
|
|
|
26
|
-
const lc = `[apps/vcs-gib/src/vcs-gib.respec.
|
|
24
|
+
const lc = `[apps/vcs-gib/src/vcs-gib.respec.mts]`;
|
|
27
25
|
|
|
28
26
|
await respecfully(lc, `vcs-gib Full Engine Cycle`, async () => {
|
|
29
27
|
|
|
@@ -36,12 +34,12 @@ await respecfully(lc, `vcs-gib Full Engine Cycle`, async () => {
|
|
|
36
34
|
|
|
37
35
|
await respecfully(lc, `Space-Qualified Addresses`, async () => {
|
|
38
36
|
await ifWe(lc, `formats and parses space-qualified addresses`, async () => {
|
|
39
|
-
const
|
|
40
|
-
iReckon(lc,
|
|
37
|
+
const sqAddr = getSpaceQualifiedIbGibAddr({ spaceId: 'space_a', ibGibAddr: 'item^gib' });
|
|
38
|
+
iReckon(lc, sqAddr).willEqual('v:1^spaceId:space_a^item^gib');
|
|
41
39
|
|
|
42
|
-
const parsed = parseSpaceQualifiedIbGibAddr(
|
|
40
|
+
const parsed = parseSpaceQualifiedIbGibAddr({ sqAddr });
|
|
43
41
|
iReckon(lc, parsed?.spaceId).willEqual('space_a');
|
|
44
|
-
iReckon(lc, parsed?.ibGibAddr).willEqual('item^
|
|
42
|
+
iReckon(lc, parsed?.ibGibAddr).willEqual('item^gib');
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
45
|
|
|
@@ -80,15 +78,23 @@ await respecfully(lc, `vcs-gib Full Engine Cycle`, async () => {
|
|
|
80
78
|
metaspace,
|
|
81
79
|
});
|
|
82
80
|
iReckon(lc, branchIbGib.data?.name).willEqual('main');
|
|
81
|
+
const branchAddr = getIbGibAddr({ ibGib: branchIbGib });
|
|
82
|
+
|
|
83
|
+
const localSpaceId = getSpaceIdFromIb(localSpace.ib);
|
|
84
|
+
const sqBranchAddr = getSpaceQualifiedIbGibAddr({
|
|
85
|
+
ibGibAddr: branchAddr,
|
|
86
|
+
spaceId: localSpaceId,
|
|
87
|
+
});
|
|
83
88
|
|
|
84
89
|
// Create Index IbGib
|
|
85
90
|
const indexIbGib = await createB2tFSIndexIbGib({
|
|
86
|
-
|
|
87
|
-
activeSpaceId: 'local_space_uuid',
|
|
91
|
+
activeSpaceId: localSpaceId,
|
|
88
92
|
space: localSpace,
|
|
93
|
+
activeBranchName: branchName,
|
|
94
|
+
sqBranchAddr,
|
|
89
95
|
metaspace,
|
|
90
96
|
});
|
|
91
|
-
iReckon(lc, indexIbGib.data?.mySpaceId).willEqual(
|
|
97
|
+
iReckon(lc, indexIbGib.data?.mySpaceId).willEqual(localSpaceId);
|
|
92
98
|
iReckon(lc, indexIbGib.data?.staged_item).willEqual([]);
|
|
93
99
|
iReckon(lc, indexIbGib.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
94
100
|
} finally {
|