@ibgib/vcs-gib 0.0.30 → 0.0.32
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.mjs +1 -1
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/add-cmd.d.mts +2 -3
- package/dist/cli/commands/add-cmd.d.mts.map +1 -1
- package/dist/cli/commands/add-cmd.mjs +30 -283
- package/dist/cli/commands/add-cmd.mjs.map +1 -1
- package/dist/cli/commands/branch-cmd.d.mts +8 -8
- package/dist/cli/commands/branch-cmd.d.mts.map +1 -1
- package/dist/cli/commands/branch-cmd.mjs +45 -176
- package/dist/cli/commands/branch-cmd.mjs.map +1 -1
- package/dist/cli/commands/checkout-cmd.d.mts +2 -4
- package/dist/cli/commands/checkout-cmd.d.mts.map +1 -1
- package/dist/cli/commands/checkout-cmd.mjs +31 -110
- package/dist/cli/commands/checkout-cmd.mjs.map +1 -1
- package/dist/cli/commands/commit-cmd.d.mts +7 -8
- package/dist/cli/commands/commit-cmd.d.mts.map +1 -1
- package/dist/cli/commands/commit-cmd.mjs +40 -390
- package/dist/cli/commands/commit-cmd.mjs.map +1 -1
- package/dist/cli/commands/generate-comment-cmd.d.mts.map +1 -1
- package/dist/cli/commands/generate-comment-cmd.mjs +5 -2
- package/dist/cli/commands/generate-comment-cmd.mjs.map +1 -1
- package/dist/cli/commands/init-cmd.d.mts +2 -2
- package/dist/cli/commands/init-cmd.d.mts.map +1 -1
- package/dist/cli/commands/init-cmd.mjs +20 -70
- package/dist/cli/commands/init-cmd.mjs.map +1 -1
- package/dist/cli/commands/log-cmd.d.mts +2 -3
- package/dist/cli/commands/log-cmd.d.mts.map +1 -1
- package/dist/cli/commands/log-cmd.mjs +42 -271
- package/dist/cli/commands/log-cmd.mjs.map +1 -1
- package/dist/cli/commands/merge-cmd.d.mts +3 -17
- package/dist/cli/commands/merge-cmd.d.mts.map +1 -1
- package/dist/cli/commands/merge-cmd.mjs +32 -218
- package/dist/cli/commands/merge-cmd.mjs.map +1 -1
- package/dist/cli/commands/reset-cmd.d.mts +1 -1
- package/dist/cli/commands/reset-cmd.d.mts.map +1 -1
- package/dist/cli/commands/reset-cmd.mjs +17 -19
- package/dist/cli/commands/reset-cmd.mjs.map +1 -1
- package/dist/cli/commands/restore-cmd.d.mts +8 -7
- package/dist/cli/commands/restore-cmd.d.mts.map +1 -1
- package/dist/cli/commands/restore-cmd.mjs +44 -62
- package/dist/cli/commands/restore-cmd.mjs.map +1 -1
- package/dist/cli/commands/status-cmd.d.mts +2 -2
- package/dist/cli/commands/status-cmd.d.mts.map +1 -1
- package/dist/cli/commands/status-cmd.mjs +63 -62
- package/dist/cli/commands/status-cmd.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/test/test-helpers.d.mts +2 -2
- package/dist/test/test-helpers.d.mts.map +1 -1
- package/package.json +3 -3
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/bootstrap/node-bootstrap.mts +1 -1
- package/src/cli/cli-e2e.respec.mts +4 -4
- package/src/cli/commands/add-cmd.mts +32 -347
- package/src/cli/commands/branch-cmd.mts +56 -225
- package/src/cli/commands/checkout-cmd.mts +34 -138
- package/src/cli/commands/commit-cmd.mts +46 -473
- package/src/cli/commands/commit-log-cmd.respec.mts +11 -7
- package/src/cli/commands/generate-comment-cmd.mts +6 -2
- package/src/cli/commands/init-cmd.mts +20 -73
- package/src/cli/commands/log-cmd.mts +41 -331
- package/src/cli/commands/merge-cmd.mts +32 -252
- package/src/cli/commands/reset-cmd.mts +17 -19
- package/src/cli/commands/restore-cmd.mts +52 -72
- package/src/cli/commands/status-add-cmd.respec.mts +3 -3
- package/src/cli/commands/status-cmd.mts +68 -63
- package/src/cli/vcs-projection-helper.mts +112 -0
- package/src/engine/branch/branch-space.respec.mts +5 -5
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +4 -4
- package/src/test/test-helpers.mts +2 -2
- package/src/vcs-gib.respec.mts +11 -8
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -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/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,37 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module commit-cmd
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* attaches comments to corresponding file and folder b2tfs_items,
|
|
7
|
-
* attaches overall commit message to root b2tfs_item, evolves root item,
|
|
8
|
-
* advances B2tFSBranchIbGib_V1 with committedPaths, and clears index staging area.
|
|
4
|
+
* CLI command handler for `vcs commit -m <message>`.
|
|
5
|
+
* Bootstraps workspace projection space and delegates to executeVcsCommit.
|
|
9
6
|
*/
|
|
10
7
|
|
|
11
8
|
import path from 'node:path';
|
|
12
9
|
import fs from 'node:fs/promises';
|
|
13
|
-
import { Dirent } from 'node:fs';
|
|
14
|
-
import crypto from 'node:crypto';
|
|
15
10
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
20
|
-
import { putInSpace, persistTransformResult } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
21
|
-
import { createCommentIbGib } from '@ibgib/core-gib/dist/common/comment/comment-helper.mjs';
|
|
22
|
-
import { CommentIbGib_V1 } from '@ibgib/core-gib/dist/common/comment/comment-types.mjs';
|
|
11
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { executeVcsCommit } from '@ibgib/core-gib/dist/vcs/commands/commit-cmd.mjs';
|
|
13
|
+
import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
23
14
|
|
|
24
15
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
25
|
-
import { getOrCreateBranchSpace } from '
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { getB2tFSBranchSpaceName, resolveContextualBranchName } from '../../engine/branch/branch-helper.mjs';
|
|
29
|
-
import { B2tFSBranchIbGib_V1 } from '../../engine/branch/branch-types.mjs';
|
|
30
|
-
import { getB2tFSIndexIbGib, updateB2tFSIndexIbGib, getSpaceQualifiedIbGibAddr } from '../../engine/index/index-helper.mjs';
|
|
31
|
-
import { B2tFSStagedItemRecord } from '../../engine/index/index-types.mjs';
|
|
32
|
-
import { isCommentMetadataFilename, extractCommentTopicName } from '../../engine/status/status-helper.mjs';
|
|
33
|
-
import { TransformResult } from '@ibgib/ts-gib/dist/types.mjs';
|
|
34
|
-
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
16
|
+
import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
|
|
17
|
+
import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
|
|
18
|
+
import { readVcsIndexProjectionFromDisk, writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
|
|
35
19
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
36
20
|
|
|
37
21
|
const lcFile = `[commit-cmd]`;
|
|
@@ -41,29 +25,29 @@ export interface CommitCmdOpts {
|
|
|
41
25
|
message?: string;
|
|
42
26
|
targetDir?: string;
|
|
43
27
|
vcsFolderName?: string;
|
|
28
|
+
author?: string;
|
|
44
29
|
quiet?: boolean;
|
|
45
30
|
}
|
|
46
31
|
|
|
47
32
|
export interface CommitCmdResult {
|
|
33
|
+
branchName: string;
|
|
48
34
|
commitAddr: string;
|
|
49
35
|
commentAddr?: string;
|
|
50
|
-
branchName: string;
|
|
51
|
-
committedPaths: string[];
|
|
52
36
|
rootItemAddr: string;
|
|
37
|
+
committedPaths: string[];
|
|
38
|
+
ingestedCommentsCount: number;
|
|
53
39
|
}
|
|
54
40
|
|
|
55
41
|
export async function executeCommitCmd({
|
|
56
|
-
message
|
|
42
|
+
message,
|
|
57
43
|
targetDir = process.cwd(),
|
|
58
44
|
vcsFolderName = '.vcsgib',
|
|
45
|
+
author = 'vcs-user',
|
|
59
46
|
quiet = false,
|
|
60
47
|
}: CommitCmdOpts = {}): Promise<CommitCmdResult> {
|
|
61
48
|
const lc = `${lcFile}[${executeCommitCmd.name}]`;
|
|
62
|
-
|
|
63
49
|
try {
|
|
64
|
-
if (logalot) {
|
|
65
|
-
console.log(`${lc} starting executeCommitCmd (I: 9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d)`);
|
|
66
|
-
}
|
|
50
|
+
if (logalot) { console.log(`${lc} starting... (I: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`); }
|
|
67
51
|
|
|
68
52
|
const absTargetDir = path.resolve(targetDir);
|
|
69
53
|
|
|
@@ -76,13 +60,13 @@ export async function executeCommitCmd({
|
|
|
76
60
|
try {
|
|
77
61
|
await fs.access(vcsPath);
|
|
78
62
|
} catch {
|
|
79
|
-
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E:
|
|
63
|
+
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d)`);
|
|
80
64
|
}
|
|
81
65
|
|
|
82
|
-
// Fetch authoritative
|
|
83
|
-
const indexIbGib = await
|
|
66
|
+
// Fetch authoritative B2tFSIndexIbGib_V1 from space
|
|
67
|
+
const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
|
|
84
68
|
if (!indexIbGib) {
|
|
85
|
-
throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E:
|
|
69
|
+
throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d)`);
|
|
86
70
|
}
|
|
87
71
|
|
|
88
72
|
const branchName = resolveContextualBranchName({
|
|
@@ -92,466 +76,55 @@ export async function executeCommitCmd({
|
|
|
92
76
|
});
|
|
93
77
|
const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
|
|
94
78
|
|
|
95
|
-
//
|
|
79
|
+
// Resolve active branch space b2s_<branchName>
|
|
96
80
|
const { space: activeSpace } = await getOrCreateBranchSpace({
|
|
97
81
|
metaspace,
|
|
98
82
|
vcsPath,
|
|
99
83
|
branchName,
|
|
100
84
|
});
|
|
101
85
|
|
|
102
|
-
|
|
103
|
-
const stagedPathsMap: { [relPath: string]: B2tFSStagedItemRecord } = { ...(indexIbGib.data?.stagedPaths || {}) };
|
|
104
|
-
const committedPaths = Object.keys(stagedPathsMap);
|
|
105
|
-
if (committedPaths.length === 0) {
|
|
106
|
-
throw new Error(`Nothing to commit (no staged items found in index) (E: 4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a)`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Find active branch node
|
|
110
|
-
let currentBranchIbGib: B2tFSBranchIbGib_V1 | undefined;
|
|
111
|
-
let currentBranchAddr: string | undefined;
|
|
112
|
-
|
|
113
|
-
const branchAddrs = [
|
|
114
|
-
...(indexIbGib.rel8ns?.branch || []),
|
|
115
|
-
...(indexIbGib.rel8ns?.branch_tjp || []),
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
if (branchAddrs.length > 0) {
|
|
119
|
-
let branchIbGibs: B2tFSBranchIbGib_V1[] = [];
|
|
120
|
-
for (const bAddr of branchAddrs) {
|
|
121
|
-
const bIbGib = await getIbGibWithMetaspaceFallback({
|
|
122
|
-
addr: bAddr,
|
|
123
|
-
space: activeSpace,
|
|
124
|
-
metaspace,
|
|
125
|
-
});
|
|
126
|
-
if (bIbGib) {
|
|
127
|
-
branchIbGibs.push(bIbGib as B2tFSBranchIbGib_V1);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
currentBranchIbGib = branchIbGibs.findLast(
|
|
132
|
-
(b) => (b as B2tFSBranchIbGib_V1)?.data?.name === branchName,
|
|
133
|
-
) as B2tFSBranchIbGib_V1 || (branchIbGibs.at(-1) as B2tFSBranchIbGib_V1);
|
|
134
|
-
|
|
135
|
-
if (currentBranchIbGib) {
|
|
136
|
-
currentBranchAddr = getIbGibAddr({ ibGib: currentBranchIbGib });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const currentRootAddr = currentBranchIbGib?.rel8ns?.b2tFS_item?.at(-1) || currentBranchIbGib?.rel8ns?.b2tfs_item?.at(-1);
|
|
141
|
-
|
|
142
|
-
// 1. Evolve root item graph with staged items and ingest co-located .ib.*.md comment files
|
|
143
|
-
const repoName = path.basename(repoRoot) || 'root';
|
|
144
|
-
let { newRootItem, newRootAddr, ingestedCommentCount } = await commitCmd_buildEvolvedRootItem({
|
|
145
|
-
currentRootAddr,
|
|
146
|
-
stagedPathsMap,
|
|
147
|
-
space: activeSpace,
|
|
86
|
+
const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
|
|
148
87
|
metaspace,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if ((!message || message.trim().length === 0) && ingestedCommentCount === 0) {
|
|
154
|
-
throw new Error(`Commit message is required (-m "message" or companion comment files) (E: 2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e)`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// 2. If CLI message is provided, attach CommentIbGib to the root b2tfs item
|
|
158
|
-
let commentAddr: string | undefined;
|
|
159
|
-
if (message && message.trim().length > 0) {
|
|
160
|
-
const commentRes = await createCommentIbGib({
|
|
161
|
-
text: message.trim(),
|
|
162
|
-
saveInSpace: true,
|
|
163
|
-
space: activeSpace,
|
|
164
|
-
});
|
|
165
|
-
const commentIbGib = commentRes.newIbGib as CommentIbGib_V1;
|
|
166
|
-
commentAddr = getIbGibAddr({ ibGib: commentIbGib });
|
|
167
|
-
await metaspace.registerNewIbGib({ ibGib: commentIbGib, space: activeSpace });
|
|
168
|
-
|
|
169
|
-
const existingComments = newRootItem.rel8ns?.comment || [];
|
|
170
|
-
const evolveRootRes = await evolveB2tFSItemIbGib({
|
|
171
|
-
existingItem: newRootItem,
|
|
172
|
-
rel8nsToUpdate: {
|
|
173
|
-
comment: [...existingComments, commentAddr],
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
await persistTransformResult({ resTransform: evolveRootRes, space: activeSpace });
|
|
177
|
-
await metaspace.registerNewIbGib({ ibGib: evolveRootRes.newIbGib, space: activeSpace });
|
|
178
|
-
|
|
179
|
-
newRootItem = evolveRootRes.newIbGib as B2tFSItemIbGib_V1;
|
|
180
|
-
newRootAddr = getIbGibAddr({ ibGib: newRootItem });
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// 3. Advance B2tFSBranchIbGib_V1 node inside activeSpace
|
|
184
|
-
const branchUuid = currentBranchIbGib?.data?.uuid || (await getUUID());
|
|
185
|
-
const newBranchRes = await Factory_V1.firstGen({
|
|
186
|
-
parentIbGib: currentBranchIbGib || ROOT,
|
|
187
|
-
ib: `b2tfs_branch ${branchName} v1 ${branchUuid}`,
|
|
188
|
-
data: {
|
|
189
|
-
...(currentBranchIbGib?.data || {}),
|
|
190
|
-
name: branchName,
|
|
191
|
-
uuid: branchUuid,
|
|
192
|
-
classname: 'B2tFSBranchIbGib_V1',
|
|
193
|
-
committedAt: new Date().toISOString(),
|
|
194
|
-
committedPaths,
|
|
195
|
-
},
|
|
196
|
-
rel8ns: {
|
|
197
|
-
b2tfs_item: [newRootAddr],
|
|
198
|
-
...(commentAddr ? { comment: [commentAddr] } : {}),
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const newBranchIbGib = newBranchRes.newIbGib as B2tFSBranchIbGib_V1;
|
|
203
|
-
const newBranchAddr = getIbGibAddr({ ibGib: newBranchIbGib });
|
|
204
|
-
await persistTransformResult({ resTransform: newBranchRes, space: activeSpace });
|
|
205
|
-
await metaspace.registerNewIbGib({ ibGib: newBranchIbGib, space: activeSpace });
|
|
206
|
-
|
|
207
|
-
const sqBranchAddr = getSpaceQualifiedIbGibAddr({
|
|
208
|
-
spaceId: activeSpace.data?.spaceSubPath || activeSpace.data?.name || getB2tFSBranchSpaceName(branchName),
|
|
209
|
-
ibGibAddr: newBranchAddr,
|
|
88
|
+
workspaceRoot: activeWorktreeDir,
|
|
89
|
+
vcsFolderName,
|
|
90
|
+
backingSpace: activeSpace,
|
|
210
91
|
});
|
|
211
92
|
|
|
212
|
-
|
|
213
|
-
const updatedIndex = await updateB2tFSIndexIbGib({
|
|
214
|
-
space: activeSpace,
|
|
93
|
+
const commitRes = await executeVcsCommit({
|
|
215
94
|
metaspace,
|
|
95
|
+
localSpace,
|
|
96
|
+
activeBranchSpace: activeSpace,
|
|
97
|
+
workspaceSpace,
|
|
216
98
|
indexIbGib,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
branch: [sqBranchAddr],
|
|
223
|
-
branch_tjp: [sqBranchAddr],
|
|
224
|
-
},
|
|
225
|
-
vcsPath,
|
|
99
|
+
message,
|
|
100
|
+
author,
|
|
101
|
+
repoRoot,
|
|
102
|
+
targetDir: absTargetDir,
|
|
103
|
+
vcsFolderName,
|
|
226
104
|
});
|
|
227
105
|
|
|
228
|
-
|
|
229
|
-
await putInSpace({ space: localSpace, ibGib: updatedIndex });
|
|
230
|
-
}
|
|
106
|
+
await writeVcsIndexProjectionToDisk({ vcsPath, indexIbGib: commitRes.updatedIndex });
|
|
231
107
|
|
|
232
108
|
if (!quiet) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
109
|
+
console.log(`[${branchName} ${commitRes.commitAddr.slice(0, 7)}] ${message || '(companion comments committed)'}`);
|
|
110
|
+
console.log(` ${commitRes.committedPaths.length} file(s) changed`);
|
|
111
|
+
if (commitRes.ingestedCommentsCount > 0) {
|
|
112
|
+
console.log(` ${commitRes.ingestedCommentsCount} companion comment(s) attached and merged`);
|
|
113
|
+
}
|
|
237
114
|
}
|
|
238
115
|
|
|
239
116
|
return {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
117
|
+
branchName: commitRes.branchName,
|
|
118
|
+
commitAddr: commitRes.commitAddr,
|
|
119
|
+
commentAddr: commitRes.commentAddr,
|
|
120
|
+
rootItemAddr: commitRes.rootItemAddr,
|
|
121
|
+
committedPaths: commitRes.committedPaths,
|
|
122
|
+
ingestedCommentsCount: commitRes.ingestedCommentsCount,
|
|
245
123
|
};
|
|
246
124
|
} catch (error) {
|
|
247
125
|
console.error(`${lc} ${extractErrorMsg(error)} (E: 6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c)`);
|
|
248
126
|
throw error;
|
|
249
127
|
} finally {
|
|
250
|
-
|
|
251
|
-
if (logalot) {
|
|
252
|
-
console.log(`${lc} complete. (I: 7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d)`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// #region commitCmd_buildEvolvedRootItem
|
|
258
|
-
async function commitCmd_buildEvolvedRootItem({
|
|
259
|
-
currentRootAddr,
|
|
260
|
-
stagedPathsMap,
|
|
261
|
-
space,
|
|
262
|
-
metaspace,
|
|
263
|
-
repoName,
|
|
264
|
-
worktreeDir,
|
|
265
|
-
}: {
|
|
266
|
-
currentRootAddr?: string;
|
|
267
|
-
stagedPathsMap: { [relPath: string]: B2tFSStagedItemRecord };
|
|
268
|
-
space: any;
|
|
269
|
-
metaspace: any;
|
|
270
|
-
repoName: string;
|
|
271
|
-
worktreeDir: string;
|
|
272
|
-
}): Promise<{ newRootItem: B2tFSItemIbGib_V1; newRootAddr: string; ingestedCommentCount: number }> {
|
|
273
|
-
let ingestedCommentCount = 0;
|
|
274
|
-
const itemsByRelPath = new Map<string, { itemAddr: string; fsType: 'file' | 'folder'; item?: B2tFSItemIbGib_V1 }>();
|
|
275
|
-
|
|
276
|
-
if (currentRootAddr) {
|
|
277
|
-
const currentRootItem = await getIbGibWithMetaspaceFallback({
|
|
278
|
-
addr: currentRootAddr,
|
|
279
|
-
space,
|
|
280
|
-
metaspace,
|
|
281
|
-
}) as B2tFSItemIbGib_V1;
|
|
282
|
-
|
|
283
|
-
if (currentRootItem) {
|
|
284
|
-
await commitCmd_walkBranchGraph({
|
|
285
|
-
item: currentRootItem,
|
|
286
|
-
space,
|
|
287
|
-
metaspace,
|
|
288
|
-
currentRelPath: '',
|
|
289
|
-
outMap: itemsByRelPath,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Overlay staged items
|
|
295
|
-
for (const [relPath, stagedRec] of Object.entries(stagedPathsMap)) {
|
|
296
|
-
itemsByRelPath.set(relPath, {
|
|
297
|
-
itemAddr: stagedRec.itemAddr,
|
|
298
|
-
fsType: stagedRec.fsType || 'file',
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// 1. Ingest co-located .ib.<filename>.md comment files for staged files
|
|
303
|
-
for (const [relPath, itemRec] of itemsByRelPath.entries()) {
|
|
304
|
-
if (itemRec.fsType !== 'file') { continue; }
|
|
305
|
-
|
|
306
|
-
const dir = path.dirname(relPath);
|
|
307
|
-
const base = path.basename(relPath);
|
|
308
|
-
const commentDir = dir === '.' ? worktreeDir : path.join(worktreeDir, dir);
|
|
309
|
-
const commentFullPath = path.join(commentDir, `.ib.${base}.md`);
|
|
310
|
-
|
|
311
|
-
let commentText = '';
|
|
312
|
-
try {
|
|
313
|
-
commentText = await fs.readFile(commentFullPath, 'utf8');
|
|
314
|
-
} catch {
|
|
315
|
-
// No comment file for this file
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (commentText.trim().length > 0) {
|
|
320
|
-
const commentRes = await createCommentIbGib({
|
|
321
|
-
text: commentText.trim(),
|
|
322
|
-
saveInSpace: true,
|
|
323
|
-
space,
|
|
324
|
-
});
|
|
325
|
-
const commentIbGib = commentRes.newIbGib as CommentIbGib_V1;
|
|
326
|
-
const commentAddr = getIbGibAddr({ ibGib: commentIbGib });
|
|
327
|
-
await metaspace.registerNewIbGib({ ibGib: commentIbGib, space });
|
|
328
|
-
ingestedCommentCount++;
|
|
329
|
-
|
|
330
|
-
const currentItem = itemRec.item || (await getIbGibWithMetaspaceFallback({
|
|
331
|
-
addr: itemRec.itemAddr,
|
|
332
|
-
space,
|
|
333
|
-
metaspace,
|
|
334
|
-
}) as B2tFSItemIbGib_V1);
|
|
335
|
-
|
|
336
|
-
if (currentItem) {
|
|
337
|
-
const existingComments = currentItem.rel8ns?.comment || [];
|
|
338
|
-
const evolvedItemRes = await evolveB2tFSItemIbGib({
|
|
339
|
-
existingItem: currentItem,
|
|
340
|
-
rel8nsToUpdate: {
|
|
341
|
-
comment: [...existingComments, commentAddr],
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
await persistTransformResult({ resTransform: evolvedItemRes, space });
|
|
345
|
-
await metaspace.registerNewIbGib({ ibGib: evolvedItemRes.newIbGib, space });
|
|
346
|
-
|
|
347
|
-
itemRec.itemAddr = getIbGibAddr({ ibGib: evolvedItemRes.newIbGib });
|
|
348
|
-
itemRec.item = evolvedItemRes.newIbGib as B2tFSItemIbGib_V1;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
try {
|
|
352
|
-
await fs.unlink(commentFullPath);
|
|
353
|
-
} catch {
|
|
354
|
-
// Delete failed / ignore
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// Ensure parent folder entries exist for all items
|
|
360
|
-
const allRelPaths = Array.from(itemsByRelPath.keys());
|
|
361
|
-
for (const relPath of allRelPaths) {
|
|
362
|
-
const parts = relPath.split('/');
|
|
363
|
-
parts.pop(); // Remove file/folder name to get parent path
|
|
364
|
-
let currentFolderRel = '';
|
|
365
|
-
for (const part of parts) {
|
|
366
|
-
currentFolderRel = currentFolderRel ? `${currentFolderRel}/${part}` : part;
|
|
367
|
-
if (!itemsByRelPath.has(currentFolderRel)) {
|
|
368
|
-
itemsByRelPath.set(currentFolderRel, { itemAddr: '', fsType: 'folder' });
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Collect all folder paths (including root '')
|
|
374
|
-
const folderPathsSet = new Set<string>();
|
|
375
|
-
folderPathsSet.add('');
|
|
376
|
-
for (const [relPath, itemRec] of itemsByRelPath.entries()) {
|
|
377
|
-
if (itemRec.fsType === 'folder' || relPath === '') {
|
|
378
|
-
folderPathsSet.add(relPath);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Sort folders deepest path first so children folders are built before parents
|
|
383
|
-
const sortedFolders = Array.from(folderPathsSet).sort((a, b) => {
|
|
384
|
-
const depthA = a ? a.split('/').length : 0;
|
|
385
|
-
const depthB = b ? b.split('/').length : 0;
|
|
386
|
-
return depthB - depthA;
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
const createdFolderAddrs = new Map<string, string>();
|
|
390
|
-
let rootFolderItem: B2tFSItemIbGib_V1 | undefined;
|
|
391
|
-
let rootFolderAddr: string = '';
|
|
392
|
-
|
|
393
|
-
for (const folderRelPath of sortedFolders) {
|
|
394
|
-
const childAddrs: string[] = [];
|
|
395
|
-
for (const [itemRelPath, itemRec] of itemsByRelPath.entries()) {
|
|
396
|
-
if (!itemRelPath || itemRelPath === folderRelPath) {
|
|
397
|
-
continue;
|
|
398
|
-
}
|
|
399
|
-
const parentRelPath = commitCmd_getParentRelPath(itemRelPath);
|
|
400
|
-
if (parentRelPath === folderRelPath) {
|
|
401
|
-
if (itemRec.fsType === 'folder') {
|
|
402
|
-
const folderAddr = createdFolderAddrs.get(itemRelPath);
|
|
403
|
-
if (folderAddr && !childAddrs.includes(folderAddr)) {
|
|
404
|
-
childAddrs.push(folderAddr);
|
|
405
|
-
}
|
|
406
|
-
} else {
|
|
407
|
-
if (itemRec.itemAddr && !childAddrs.includes(itemRec.itemAddr)) {
|
|
408
|
-
childAddrs.push(itemRec.itemAddr);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Check for folder-level .ib.<topic>.md files in this folder
|
|
415
|
-
const folderDiskPath = folderRelPath ? path.join(worktreeDir, folderRelPath) : worktreeDir;
|
|
416
|
-
const folderCommentAddrs: string[] = [];
|
|
417
|
-
|
|
418
|
-
try {
|
|
419
|
-
const dirents = await fs.readdir(folderDiskPath, { withFileTypes: true });
|
|
420
|
-
for (const dirent of dirents) {
|
|
421
|
-
if (dirent.isFile() && isCommentMetadataFilename(dirent.name)) {
|
|
422
|
-
const topicName = extractCommentTopicName(dirent.name);
|
|
423
|
-
const isCoLocatedFileComment = itemsByRelPath.has(folderRelPath ? `${folderRelPath}/${topicName}` : topicName);
|
|
424
|
-
|
|
425
|
-
if (!isCoLocatedFileComment) {
|
|
426
|
-
const fullCommentPath = path.join(folderDiskPath, dirent.name);
|
|
427
|
-
const commentContent = await fs.readFile(fullCommentPath, 'utf8');
|
|
428
|
-
|
|
429
|
-
if (commentContent.trim().length > 0) {
|
|
430
|
-
const commentRes = await createCommentIbGib({
|
|
431
|
-
text: commentContent.trim(),
|
|
432
|
-
saveInSpace: true,
|
|
433
|
-
space,
|
|
434
|
-
});
|
|
435
|
-
const commentIbGib = commentRes.newIbGib as CommentIbGib_V1;
|
|
436
|
-
const cAddr = getIbGibAddr({ ibGib: commentIbGib });
|
|
437
|
-
await metaspace.registerNewIbGib({ ibGib: commentIbGib, space });
|
|
438
|
-
folderCommentAddrs.push(cAddr);
|
|
439
|
-
ingestedCommentCount++;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
try {
|
|
443
|
-
await fs.unlink(fullCommentPath);
|
|
444
|
-
} catch {
|
|
445
|
-
// ignore delete error
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
} catch {
|
|
451
|
-
// Folder may not exist on disk
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
const folderName = folderRelPath ? path.basename(folderRelPath) : repoName;
|
|
455
|
-
const nameHash = crypto.createHash('sha256').update(folderName).digest('hex');
|
|
456
|
-
|
|
457
|
-
const existingFolderRec = itemsByRelPath.get(folderRelPath);
|
|
458
|
-
|
|
459
|
-
let folderRes: TransformResult<IbGib_V1>;
|
|
460
|
-
|
|
461
|
-
if (existingFolderRec && existingFolderRec.item) {
|
|
462
|
-
const oldChildAddrs = existingFolderRec.item.rel8ns?.[B2TFS_CHILD_ITEM_REL8N_NAME] || [];
|
|
463
|
-
const toRemoveChildAddrs = oldChildAddrs.filter(a => !childAddrs.includes(a));
|
|
464
|
-
const existingComments = existingFolderRec.item.rel8ns?.comment || [];
|
|
465
|
-
|
|
466
|
-
folderRes = await evolveB2tFSItemIbGib({
|
|
467
|
-
existingItem: existingFolderRec.item,
|
|
468
|
-
dataToUpdate: {
|
|
469
|
-
nameHash,
|
|
470
|
-
},
|
|
471
|
-
rel8nsToUpdate: {
|
|
472
|
-
...(childAddrs.length > 0 ? { [B2TFS_CHILD_ITEM_REL8N_NAME]: childAddrs } : {}),
|
|
473
|
-
...(folderCommentAddrs.length > 0 ? { comment: [...existingComments, ...folderCommentAddrs] } : {}),
|
|
474
|
-
},
|
|
475
|
-
rel8nsToRemove: toRemoveChildAddrs.length > 0 ? { [B2TFS_CHILD_ITEM_REL8N_NAME]: toRemoveChildAddrs } : undefined,
|
|
476
|
-
});
|
|
477
|
-
} else {
|
|
478
|
-
folderRes = await createB2tFSItemIbGib({
|
|
479
|
-
fsType: 'folder',
|
|
480
|
-
name: folderName,
|
|
481
|
-
data: {
|
|
482
|
-
nameHash,
|
|
483
|
-
},
|
|
484
|
-
rel8ns: {
|
|
485
|
-
...(childAddrs.length > 0 ? { [B2TFS_CHILD_ITEM_REL8N_NAME]: childAddrs } : {}),
|
|
486
|
-
...(folderCommentAddrs.length > 0 ? { comment: folderCommentAddrs } : {}),
|
|
487
|
-
},
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
const folderItem = folderRes.newIbGib as B2tFSItemIbGib_V1;
|
|
492
|
-
const folderAddr = getIbGibAddr({ ibGib: folderItem });
|
|
493
|
-
await persistTransformResult({ resTransform: folderRes, space });
|
|
494
|
-
await metaspace.registerNewIbGib({ ibGib: folderItem, space });
|
|
495
|
-
|
|
496
|
-
createdFolderAddrs.set(folderRelPath, folderAddr);
|
|
497
|
-
|
|
498
|
-
if (folderRelPath === '') {
|
|
499
|
-
rootFolderItem = folderItem;
|
|
500
|
-
rootFolderAddr = folderAddr;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
return { newRootItem: rootFolderItem!, newRootAddr: rootFolderAddr, ingestedCommentCount };
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function commitCmd_getParentRelPath(relPath: string): string {
|
|
508
|
-
const parts = relPath.split('/');
|
|
509
|
-
parts.pop();
|
|
510
|
-
return parts.join('/');
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
async function commitCmd_walkBranchGraph({
|
|
514
|
-
item,
|
|
515
|
-
space,
|
|
516
|
-
metaspace,
|
|
517
|
-
currentRelPath,
|
|
518
|
-
outMap,
|
|
519
|
-
}: {
|
|
520
|
-
item: B2tFSItemIbGib_V1;
|
|
521
|
-
space: any;
|
|
522
|
-
metaspace?: any;
|
|
523
|
-
currentRelPath: string;
|
|
524
|
-
outMap: Map<string, { itemAddr: string; fsType: 'file' | 'folder'; item?: B2tFSItemIbGib_V1 }>;
|
|
525
|
-
}): Promise<void> {
|
|
526
|
-
if (!item || !item.data) { return; }
|
|
527
|
-
|
|
528
|
-
const { fsType } = item.data;
|
|
529
|
-
const itemAddr = getIbGibAddr({ ibGib: item });
|
|
530
|
-
|
|
531
|
-
outMap.set(currentRelPath, { itemAddr, fsType, item });
|
|
532
|
-
|
|
533
|
-
if (fsType === 'folder') {
|
|
534
|
-
const childAddrs = item.rel8ns?.[B2TFS_CHILD_ITEM_REL8N_NAME] || [];
|
|
535
|
-
for (const childAddr of childAddrs) {
|
|
536
|
-
const childItem = await getIbGibWithMetaspaceFallback({
|
|
537
|
-
addr: childAddr,
|
|
538
|
-
space,
|
|
539
|
-
metaspace,
|
|
540
|
-
}) as B2tFSItemIbGib_V1;
|
|
541
|
-
|
|
542
|
-
if (childItem && childItem.data) {
|
|
543
|
-
const childRelPath = currentRelPath
|
|
544
|
-
? `${currentRelPath}/${childItem.data.name}`
|
|
545
|
-
: childItem.data.name;
|
|
546
|
-
await commitCmd_walkBranchGraph({
|
|
547
|
-
item: childItem,
|
|
548
|
-
space,
|
|
549
|
-
metaspace,
|
|
550
|
-
currentRelPath: childRelPath,
|
|
551
|
-
outMap,
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
}
|
|
128
|
+
if (logalot) { console.log(`${lc} complete. (I: 7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d)`); }
|
|
555
129
|
}
|
|
556
130
|
}
|
|
557
|
-
// #endregion commitCmd_buildEvolvedRootItem
|
|
@@ -23,9 +23,9 @@ import { executeCheckoutCmd } from './checkout-cmd.mjs';
|
|
|
23
23
|
import { executeMergeCmd } from './merge-cmd.mjs';
|
|
24
24
|
import { executeGenerateCommentCmd } from './generate-comment-cmd.mjs';
|
|
25
25
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
26
|
-
import {
|
|
27
|
-
import { getOrCreateBranchSpace } from '
|
|
28
|
-
import { getIbGibWithMetaspaceFallback } from '
|
|
26
|
+
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
27
|
+
import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
|
|
28
|
+
import { getIbGibWithMetaspaceFallback } from '@ibgib/core-gib/dist/vcs/item/item-helper.mjs';
|
|
29
29
|
|
|
30
30
|
const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.node.mts]`;
|
|
31
31
|
|
|
@@ -119,7 +119,7 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
119
119
|
repoPath: testDir,
|
|
120
120
|
vcsFolderName,
|
|
121
121
|
});
|
|
122
|
-
const indexAdd = await
|
|
122
|
+
const indexAdd = await readVcsIndexProjectionFromDisk({ space: spaceAdd, vcsPath: vcsPathAdd });
|
|
123
123
|
iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
|
|
124
124
|
iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
125
125
|
|
|
@@ -134,7 +134,7 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
134
134
|
repoPath: testDir,
|
|
135
135
|
vcsFolderName,
|
|
136
136
|
});
|
|
137
|
-
const indexCommit = await
|
|
137
|
+
const indexCommit = await readVcsIndexProjectionFromDisk({ space: spaceCommit, vcsPath: vcsPathCommit });
|
|
138
138
|
iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
|
|
139
139
|
iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
140
140
|
|
|
@@ -458,8 +458,12 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
458
458
|
vcsPath,
|
|
459
459
|
branchName: 'main',
|
|
460
460
|
});
|
|
461
|
-
const indexIbGib = await
|
|
462
|
-
const
|
|
461
|
+
const indexIbGib = await readVcsIndexProjectionFromDisk({ space: metaspace.zeroSpace, vcsPath });
|
|
462
|
+
const branchAddrs = [
|
|
463
|
+
...(indexIbGib?.rel8ns?.branch || []),
|
|
464
|
+
...(indexIbGib?.rel8ns?.branch_tjp || []),
|
|
465
|
+
];
|
|
466
|
+
const mainBranchAddr = branchAddrs.find(a => a.includes('main')) || branchAddrs.at(-1);
|
|
463
467
|
const mainBranch = await getIbGibWithMetaspaceFallback({ addr: mainBranchAddr!, space: mainSpace, metaspace });
|
|
464
468
|
const mainRootAddr = mainBranch?.rel8ns?.b2tfs_item?.at(-1);
|
|
465
469
|
const mainRoot = await getIbGibWithMetaspaceFallback({ addr: mainRootAddr!, space: mainSpace, metaspace });
|
|
@@ -11,7 +11,8 @@ import fs from 'node:fs/promises';
|
|
|
11
11
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
12
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
13
13
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
14
|
-
import { getRepoStatus } from '
|
|
14
|
+
import { getRepoStatus } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
|
|
15
|
+
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
15
16
|
|
|
16
17
|
const lcFile = `[generate-comment-cmd]`;
|
|
17
18
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
@@ -40,7 +41,7 @@ export async function executeGenerateCommentCmd({
|
|
|
40
41
|
|
|
41
42
|
try {
|
|
42
43
|
if (logalot) {
|
|
43
|
-
console.log(`${lc} starting
|
|
44
|
+
console.log(`${lc} starting... (I: 8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e)`);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const absTargetDir = path.resolve(targetDir);
|
|
@@ -57,9 +58,12 @@ export async function executeGenerateCommentCmd({
|
|
|
57
58
|
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f)`);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
|
|
62
|
+
|
|
60
63
|
const statusRes = await getRepoStatus({
|
|
61
64
|
metaspace,
|
|
62
65
|
localSpace,
|
|
66
|
+
indexIbGib,
|
|
63
67
|
vcsPath,
|
|
64
68
|
repoRoot,
|
|
65
69
|
vcsFolderName,
|