@ibgib/vcs-gib 0.0.23 → 0.0.29
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/CHANGELOG.md +22 -0
- package/VCS_CLI_USER_GUIDE.md +94 -89
- package/dist/AUTO-GENERATED-version.d.mts +1 -1
- package/dist/AUTO-GENERATED-version.mjs +1 -1
- package/dist/cli/cli-arg-parser.d.mts +1 -0
- package/dist/cli/cli-arg-parser.d.mts.map +1 -1
- package/dist/cli/cli-arg-parser.mjs +5 -1
- package/dist/cli/cli-arg-parser.mjs.map +1 -1
- package/dist/cli/cli-constants.d.mts +6 -0
- package/dist/cli/cli-constants.d.mts.map +1 -1
- package/dist/cli/cli-constants.mjs +12 -0
- package/dist/cli/cli-constants.mjs.map +1 -1
- package/dist/cli/commands/add-cmd.d.mts.map +1 -1
- package/dist/cli/commands/add-cmd.mjs +11 -3
- package/dist/cli/commands/add-cmd.mjs.map +1 -1
- package/dist/cli/commands/commit-cmd.d.mts +5 -4
- package/dist/cli/commands/commit-cmd.d.mts.map +1 -1
- package/dist/cli/commands/commit-cmd.mjs +155 -35
- package/dist/cli/commands/commit-cmd.mjs.map +1 -1
- package/dist/cli/commands/generate-comment-cmd.d.mts +19 -0
- package/dist/cli/commands/generate-comment-cmd.d.mts.map +1 -0
- package/dist/cli/commands/generate-comment-cmd.mjs +140 -0
- package/dist/cli/commands/generate-comment-cmd.mjs.map +1 -0
- package/dist/cli/commands/log-cmd.d.mts +12 -3
- package/dist/cli/commands/log-cmd.d.mts.map +1 -1
- package/dist/cli/commands/log-cmd.mjs +242 -39
- package/dist/cli/commands/log-cmd.mjs.map +1 -1
- package/dist/cli/commands/status-cmd.d.mts +5 -6
- package/dist/cli/commands/status-cmd.d.mts.map +1 -1
- package/dist/cli/commands/status-cmd.mjs +51 -205
- package/dist/cli/commands/status-cmd.mjs.map +1 -1
- package/dist/cli/vcs-cli-main.d.mts.map +1 -1
- package/dist/cli/vcs-cli-main.mjs +25 -4
- package/dist/cli/vcs-cli-main.mjs.map +1 -1
- package/dist/engine/branch/branch-helper.d.mts +14 -0
- package/dist/engine/branch/branch-helper.d.mts.map +1 -1
- package/dist/engine/branch/branch-helper.mjs +21 -0
- package/dist/engine/branch/branch-helper.mjs.map +1 -1
- package/dist/engine/index/index-helper.d.mts.map +1 -1
- package/dist/engine/index/index-helper.mjs +3 -0
- package/dist/engine/index/index-helper.mjs.map +1 -1
- package/dist/engine/item/item-helper.d.mts.map +1 -1
- package/dist/engine/item/item-helper.mjs +5 -2
- package/dist/engine/item/item-helper.mjs.map +1 -1
- package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts +28 -0
- package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts.map +1 -1
- package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs +84 -12
- package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs.map +1 -1
- package/dist/engine/status/status-helper.d.mts +90 -0
- package/dist/engine/status/status-helper.d.mts.map +1 -0
- package/dist/engine/status/status-helper.mjs +286 -0
- package/dist/engine/status/status-helper.mjs.map +1 -0
- package/package.json +3 -3
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/cli/cli-arg-parser.mts +5 -0
- package/src/cli/cli-constants.mts +13 -0
- package/src/cli/commands/add-cmd.mts +11 -3
- package/src/cli/commands/branch-checkout-cmd.respec.mts +54 -0
- package/src/cli/commands/commit-cmd.mts +171 -44
- package/src/cli/commands/commit-log-cmd.respec.mts +216 -3
- package/src/cli/commands/generate-comment-cmd.mts +171 -0
- package/src/cli/commands/log-cmd.mts +294 -42
- package/src/cli/commands/status-cmd.mts +58 -256
- package/src/cli/vcs-cli-main.mts +25 -4
- package/src/engine/branch/branch-helper.mts +33 -0
- package/src/engine/index/index-helper.mts +3 -0
- package/src/engine/item/item-helper.mts +5 -2
- package/src/engine/merge/b2tfs-3way-graft-strategy.mts +89 -10
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +399 -0
- package/src/engine/status/status-helper.mts +383 -0
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module status-helper
|
|
3
|
+
*
|
|
4
|
+
* Pure status inspection helpers and pending `.ib.*.md` comment metadata detection.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import fs from 'node:fs/promises';
|
|
8
|
+
import crypto from 'node:crypto';
|
|
9
|
+
import { B2TFS_CHILD_ITEM_REL8N_NAME } from '../item/item-types.mjs';
|
|
10
|
+
import { getIbGibWithMetaspaceFallback } from '../item/item-helper.mjs';
|
|
11
|
+
import { isPathFiltered, parseFilterFileContent } from '../filter/glob-helper.mjs';
|
|
12
|
+
import { getB2tFSIndexIbGib } from '../index/index-helper.mjs';
|
|
13
|
+
import { getOrCreateBranchSpace } from '../branch/branch-space-helper.mjs';
|
|
14
|
+
import { resolveContextualBranchName } from '../branch/branch-helper.mjs';
|
|
15
|
+
/**
|
|
16
|
+
* Returns true if filename is a `.ib.*.md` comment metadata file.
|
|
17
|
+
*/
|
|
18
|
+
export function isCommentMetadataFilename(filename) {
|
|
19
|
+
return filename.startsWith('.ib.') && filename.endsWith('.md') && filename.length > '.ib..md'.length;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extracts the inner topic / filename from `.ib.<topic>.md`.
|
|
23
|
+
*/
|
|
24
|
+
export function extractCommentTopicName(filename) {
|
|
25
|
+
if (!isCommentMetadataFilename(filename)) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
return filename.slice(4, -3); // strips leading '.ib.' and trailing '.md'
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pure helper to walk the branch graph items.
|
|
32
|
+
*/
|
|
33
|
+
export async function walkBranchGraph({ item, space, metaspace, currentRelPath, outMap, }) {
|
|
34
|
+
if (!item || !item.data) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const { fsType, fileHash } = item.data;
|
|
38
|
+
if (currentRelPath) {
|
|
39
|
+
outMap.set(currentRelPath, { relPath: currentRelPath, fileHash, fsType });
|
|
40
|
+
}
|
|
41
|
+
if (fsType === 'folder') {
|
|
42
|
+
const childAddrs = item.rel8ns?.[B2TFS_CHILD_ITEM_REL8N_NAME] || [];
|
|
43
|
+
for (const childAddr of childAddrs) {
|
|
44
|
+
const childItem = await getIbGibWithMetaspaceFallback({
|
|
45
|
+
addr: childAddr,
|
|
46
|
+
space,
|
|
47
|
+
metaspace,
|
|
48
|
+
});
|
|
49
|
+
if (childItem && childItem.data) {
|
|
50
|
+
const childRelPath = currentRelPath
|
|
51
|
+
? `${currentRelPath}/${childItem.data.name}`
|
|
52
|
+
: childItem.data.name;
|
|
53
|
+
await walkBranchGraph({
|
|
54
|
+
item: childItem,
|
|
55
|
+
space,
|
|
56
|
+
metaspace,
|
|
57
|
+
currentRelPath: childRelPath,
|
|
58
|
+
outMap,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Pure helper to scan physical workspace, separating source files from `.ib.*.md` comment files.
|
|
66
|
+
*/
|
|
67
|
+
export async function scanPhysicalWorkspace({ dirPath, baseDir, vcsFolderName, filterPatterns, outSourceMap, outCommentFiles, }) {
|
|
68
|
+
let entries = [];
|
|
69
|
+
try {
|
|
70
|
+
entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
const fullEntryPath = path.join(dirPath, entry.name);
|
|
77
|
+
const relPath = path.relative(baseDir, fullEntryPath).replace(/\\/g, '/');
|
|
78
|
+
// Ignore vcs storage folder, .git, and worktrees folder b
|
|
79
|
+
if (relPath === vcsFolderName || relPath.startsWith(vcsFolderName + '/') ||
|
|
80
|
+
relPath === '.git' || relPath.startsWith('.git/') ||
|
|
81
|
+
relPath === 'b' || relPath.startsWith('b/')) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (isPathFiltered({ relativePath: relPath, isDirectory: entry.isDirectory(), filterPatterns })) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (entry.isDirectory()) {
|
|
88
|
+
outSourceMap.set(relPath, { relPath, fullPath: fullEntryPath, isDirectory: true });
|
|
89
|
+
await scanPhysicalWorkspace({
|
|
90
|
+
dirPath: fullEntryPath,
|
|
91
|
+
baseDir,
|
|
92
|
+
vcsFolderName,
|
|
93
|
+
filterPatterns,
|
|
94
|
+
outSourceMap,
|
|
95
|
+
outCommentFiles,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (entry.isFile()) {
|
|
99
|
+
if (isCommentMetadataFilename(entry.name)) {
|
|
100
|
+
const parentRelPath = path.relative(baseDir, dirPath).replace(/\\/g, '/');
|
|
101
|
+
outCommentFiles.push({
|
|
102
|
+
relPath,
|
|
103
|
+
fullPath: fullEntryPath,
|
|
104
|
+
parentRelPath: parentRelPath === '.' ? '' : parentRelPath,
|
|
105
|
+
filename: entry.name,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
let fileHash;
|
|
110
|
+
try {
|
|
111
|
+
const fileData = await fs.readFile(fullEntryPath);
|
|
112
|
+
fileHash = crypto.createHash('sha256').update(fileData).digest('hex');
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// File unreadable
|
|
116
|
+
}
|
|
117
|
+
outSourceMap.set(relPath, { relPath, fullPath: fullEntryPath, isDirectory: false, fileHash });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Computes complete repository status, including staged, modified, deleted, untracked,
|
|
124
|
+
* and mapped pending `.ib.*.md` comment files.
|
|
125
|
+
*/
|
|
126
|
+
export async function getRepoStatus({ metaspace, localSpace, vcsPath, repoRoot, targetDir = repoRoot, vcsFolderName = '.vcsgib', }) {
|
|
127
|
+
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, vcsPath });
|
|
128
|
+
const branchName = resolveContextualBranchName({ targetDir, repoRoot, indexIbGib });
|
|
129
|
+
const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
|
|
130
|
+
const { space: activeBranchSpace } = await getOrCreateBranchSpace({
|
|
131
|
+
metaspace,
|
|
132
|
+
vcsPath,
|
|
133
|
+
branchName,
|
|
134
|
+
});
|
|
135
|
+
const stagedMap = new Map();
|
|
136
|
+
const indexStagedPaths = indexIbGib?.data?.stagedPaths || {};
|
|
137
|
+
for (const [relPath, itemRec] of Object.entries(indexStagedPaths)) {
|
|
138
|
+
stagedMap.set(relPath, itemRec);
|
|
139
|
+
}
|
|
140
|
+
let rootItemAddr;
|
|
141
|
+
const branchAddrs = [
|
|
142
|
+
...(indexIbGib?.rel8ns?.branch || []),
|
|
143
|
+
...(indexIbGib?.rel8ns?.branch_tjp || []),
|
|
144
|
+
];
|
|
145
|
+
if (branchAddrs.length > 0) {
|
|
146
|
+
let branchIbGibs = [];
|
|
147
|
+
for (const bAddr of branchAddrs) {
|
|
148
|
+
const bIbGib = await getIbGibWithMetaspaceFallback({
|
|
149
|
+
addr: bAddr,
|
|
150
|
+
space: activeBranchSpace,
|
|
151
|
+
metaspace,
|
|
152
|
+
});
|
|
153
|
+
if (bIbGib) {
|
|
154
|
+
branchIbGibs.push(bIbGib);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const activeBranchIbGib = branchIbGibs.find((b) => b?.data?.name === branchName) || branchIbGibs.at(0);
|
|
158
|
+
rootItemAddr = activeBranchIbGib?.rel8ns?.b2tFS_item?.at(0) || activeBranchIbGib?.rel8ns?.b2tfs_item?.at(0);
|
|
159
|
+
}
|
|
160
|
+
let filterPatterns = [];
|
|
161
|
+
const ignorePath = path.join(activeWorktreeDir, '.ibgibignore');
|
|
162
|
+
try {
|
|
163
|
+
const ignoreContent = await fs.readFile(ignorePath, 'utf8');
|
|
164
|
+
filterPatterns = parseFilterFileContent(ignoreContent);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// Ignore file missing is fine
|
|
168
|
+
}
|
|
169
|
+
const branchItemsMap = new Map();
|
|
170
|
+
if (rootItemAddr) {
|
|
171
|
+
const rootItem = await getIbGibWithMetaspaceFallback({
|
|
172
|
+
addr: rootItemAddr,
|
|
173
|
+
space: activeBranchSpace,
|
|
174
|
+
metaspace,
|
|
175
|
+
});
|
|
176
|
+
if (rootItem) {
|
|
177
|
+
await walkBranchGraph({
|
|
178
|
+
item: rootItem,
|
|
179
|
+
space: activeBranchSpace,
|
|
180
|
+
metaspace,
|
|
181
|
+
currentRelPath: '',
|
|
182
|
+
outMap: branchItemsMap,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const physicalItemsMap = new Map();
|
|
187
|
+
const rawCommentFiles = [];
|
|
188
|
+
await scanPhysicalWorkspace({
|
|
189
|
+
dirPath: activeWorktreeDir,
|
|
190
|
+
baseDir: activeWorktreeDir,
|
|
191
|
+
vcsFolderName,
|
|
192
|
+
filterPatterns,
|
|
193
|
+
outSourceMap: physicalItemsMap,
|
|
194
|
+
outCommentFiles: rawCommentFiles,
|
|
195
|
+
});
|
|
196
|
+
const staged = [];
|
|
197
|
+
const modified = [];
|
|
198
|
+
const deleted = [];
|
|
199
|
+
const untracked = [];
|
|
200
|
+
for (const [relPath, stagedRec] of stagedMap.entries()) {
|
|
201
|
+
staged.push({
|
|
202
|
+
path: relPath,
|
|
203
|
+
fsType: stagedRec.fsType || 'file',
|
|
204
|
+
status: 'staged',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
for (const [relPath, physItem] of physicalItemsMap.entries()) {
|
|
208
|
+
if (stagedMap.has(relPath)) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const branchItem = branchItemsMap.get(relPath);
|
|
212
|
+
if (!branchItem) {
|
|
213
|
+
untracked.push({
|
|
214
|
+
path: relPath,
|
|
215
|
+
fsType: physItem.isDirectory ? 'folder' : 'file',
|
|
216
|
+
status: 'untracked',
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
if (!physItem.isDirectory && physItem.fileHash && branchItem.fileHash && physItem.fileHash !== branchItem.fileHash) {
|
|
221
|
+
modified.push({
|
|
222
|
+
path: relPath,
|
|
223
|
+
fsType: 'file',
|
|
224
|
+
status: 'modified',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (const [relPath, branchItem] of branchItemsMap.entries()) {
|
|
230
|
+
if (!relPath || relPath === '.' || relPath === '') {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (!physicalItemsMap.has(relPath) && !stagedMap.has(relPath)) {
|
|
234
|
+
deleted.push({
|
|
235
|
+
path: relPath,
|
|
236
|
+
fsType: branchItem.fsType,
|
|
237
|
+
status: 'deleted',
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Map raw comment files to targets (file or folder)
|
|
242
|
+
const pendingComments = [];
|
|
243
|
+
for (const raw of rawCommentFiles) {
|
|
244
|
+
const topicName = extractCommentTopicName(raw.filename);
|
|
245
|
+
const candidateFileRelPath = raw.parentRelPath ? `${raw.parentRelPath}/${topicName}` : topicName;
|
|
246
|
+
let targetType = 'folder';
|
|
247
|
+
let targetRelPath = raw.parentRelPath;
|
|
248
|
+
if (physicalItemsMap.has(candidateFileRelPath) && !physicalItemsMap.get(candidateFileRelPath)?.isDirectory) {
|
|
249
|
+
targetType = 'file';
|
|
250
|
+
targetRelPath = candidateFileRelPath;
|
|
251
|
+
}
|
|
252
|
+
else if (branchItemsMap.has(candidateFileRelPath) && branchItemsMap.get(candidateFileRelPath)?.fsType === 'file') {
|
|
253
|
+
targetType = 'file';
|
|
254
|
+
targetRelPath = candidateFileRelPath;
|
|
255
|
+
}
|
|
256
|
+
else if (stagedMap.has(candidateFileRelPath)) {
|
|
257
|
+
targetType = 'file';
|
|
258
|
+
targetRelPath = candidateFileRelPath;
|
|
259
|
+
}
|
|
260
|
+
let content = '';
|
|
261
|
+
try {
|
|
262
|
+
content = await fs.readFile(raw.fullPath, 'utf8');
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// Unreadable comment file
|
|
266
|
+
}
|
|
267
|
+
pendingComments.push({
|
|
268
|
+
commentRelPath: raw.relPath,
|
|
269
|
+
commentFullPath: raw.fullPath,
|
|
270
|
+
targetRelPath,
|
|
271
|
+
targetType,
|
|
272
|
+
topicName,
|
|
273
|
+
content,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
branchName,
|
|
278
|
+
activeWorktreeDir,
|
|
279
|
+
staged,
|
|
280
|
+
modified,
|
|
281
|
+
deleted,
|
|
282
|
+
untracked,
|
|
283
|
+
pendingComments,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=status-helper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-helper.mjs","sourceRoot":"","sources":["../../../src/engine/status/status-helper.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElC,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAqB,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAA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C;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/vcs-gib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@ibgib/helper-gib": "^0.0.37",
|
|
23
23
|
"@ibgib/ts-gib": "^0.5.34",
|
|
24
24
|
"@ibgib/encrypt-gib": "^0.3.1",
|
|
25
|
-
"@ibgib/core-gib": "^0.1.
|
|
26
|
-
"@ibgib/node-gib": "^0.0.
|
|
25
|
+
"@ibgib/core-gib": "^0.1.76",
|
|
26
|
+
"@ibgib/node-gib": "^0.0.21"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
VCS_PARAM_YES,
|
|
19
19
|
VCS_PARAM_STAGED,
|
|
20
20
|
VCS_PARAM_WORKTREE,
|
|
21
|
+
VCS_PARAM_COMMENTS,
|
|
21
22
|
} from './cli-constants.mjs';
|
|
22
23
|
|
|
23
24
|
export type VcsSubcommand = typeof VCS_SUBCOMMANDS[keyof typeof VCS_SUBCOMMANDS];
|
|
@@ -36,6 +37,7 @@ export interface ParsedVcsArgs {
|
|
|
36
37
|
yes?: boolean;
|
|
37
38
|
staged?: boolean;
|
|
38
39
|
worktree?: boolean;
|
|
40
|
+
comments?: boolean;
|
|
39
41
|
};
|
|
40
42
|
rawArgs: string[];
|
|
41
43
|
}
|
|
@@ -104,6 +106,9 @@ export function parseVcsArgs(argv: string[]): ParsedVcsArgs {
|
|
|
104
106
|
} else if (matchesParam(arg, VCS_PARAM_WORKTREE)) {
|
|
105
107
|
flags.worktree = true;
|
|
106
108
|
i++;
|
|
109
|
+
} else if (matchesParam(arg, VCS_PARAM_COMMENTS)) {
|
|
110
|
+
flags.comments = true;
|
|
111
|
+
i++;
|
|
107
112
|
} else if (!arg.startsWith('-')) {
|
|
108
113
|
if (command === VCS_SUBCOMMANDS.HELP) {
|
|
109
114
|
const normalized = arg.toLowerCase();
|
|
@@ -19,10 +19,23 @@ export const VCS_SUBCOMMANDS = {
|
|
|
19
19
|
MERGE: 'merge',
|
|
20
20
|
RESET: 'reset',
|
|
21
21
|
RESTORE: 'restore',
|
|
22
|
+
GENERATE_COMMENT: 'generate-comment',
|
|
23
|
+
GEN_COMMENT: 'gen-comment',
|
|
24
|
+
GEN_MSG: 'gen-msg',
|
|
25
|
+
GCOMM: 'gcomm',
|
|
26
|
+
GMSG: 'gmsg',
|
|
22
27
|
HELP: 'help',
|
|
23
28
|
VERSION: 'version',
|
|
24
29
|
} as const;
|
|
25
30
|
|
|
31
|
+
export const VCS_PARAM_COMMENTS: RCLIParamInfo = {
|
|
32
|
+
name: 'comments',
|
|
33
|
+
synonyms: ['c'],
|
|
34
|
+
description: 'Show full pending comment texts in status',
|
|
35
|
+
isFlag: true,
|
|
36
|
+
argTypeName: 'boolean',
|
|
37
|
+
};
|
|
38
|
+
|
|
26
39
|
export const VCS_PARAM_MESSAGE: RCLIParamInfo = {
|
|
27
40
|
name: 'message',
|
|
28
41
|
synonyms: ['m'],
|
|
@@ -20,6 +20,8 @@ import { putInSpace, persistTransformResult } from '@ibgib/core-gib/dist/witness
|
|
|
20
20
|
|
|
21
21
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
22
22
|
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
23
|
+
import { resolveContextualBranchName } from '../../engine/branch/branch-helper.mjs';
|
|
24
|
+
import { isCommentMetadataFilename } from '../../engine/status/status-helper.mjs';
|
|
23
25
|
import { getB2tFSItemIb } from '../../engine/item/item-atom-helper.mjs';
|
|
24
26
|
import { B2tFSItemIbGib_V1, B2TFS_CHILD_ITEM_REL8N_NAME } from '../../engine/item/item-types.mjs';
|
|
25
27
|
import { getIbGibWithMetaspaceFallback, createB2tFSItemIbGib, evolveB2tFSItemIbGib } from '../../engine/item/item-helper.mjs';
|
|
@@ -78,7 +80,11 @@ export async function executeAddCmd({
|
|
|
78
80
|
throw new Error(`Repository not initialized. Run 'vcs init' first. (E: 2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e)`);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
const activeBranch =
|
|
83
|
+
const activeBranch = resolveContextualBranchName({
|
|
84
|
+
targetDir: absTargetDir,
|
|
85
|
+
repoRoot,
|
|
86
|
+
indexIbGib,
|
|
87
|
+
});
|
|
82
88
|
const activeWorktreeDir = activeBranch === 'main' ? repoRoot : path.join(repoRoot, 'b', activeBranch);
|
|
83
89
|
|
|
84
90
|
// Target active branch space b2s_<activeBranch>
|
|
@@ -186,7 +192,7 @@ export async function executeAddCmd({
|
|
|
186
192
|
throw new Error(`No files matched glob pattern: ${relOrAbs} (E: e23d4c5f6a7b8c9d0e1f2a3b4c5d6e7f)`);
|
|
187
193
|
}
|
|
188
194
|
} else {
|
|
189
|
-
const fullPath = path.resolve(
|
|
195
|
+
const fullPath = path.isAbsolute(relOrAbs) ? relOrAbs : path.resolve(absTargetDir, relOrAbs);
|
|
190
196
|
let stat;
|
|
191
197
|
try {
|
|
192
198
|
stat = await fs.stat(fullPath);
|
|
@@ -420,7 +426,9 @@ async function addCmd_collectFilesRecursively({
|
|
|
420
426
|
outFiles,
|
|
421
427
|
});
|
|
422
428
|
} else if (entry.isFile()) {
|
|
423
|
-
|
|
429
|
+
if (!isCommentMetadataFilename(entry.name)) {
|
|
430
|
+
outFiles.push(fullPath);
|
|
431
|
+
}
|
|
424
432
|
}
|
|
425
433
|
}
|
|
426
434
|
}
|
|
@@ -19,6 +19,7 @@ import { executeBranchCmd } from './branch-cmd.mjs';
|
|
|
19
19
|
import { executeCheckoutCmd } from './checkout-cmd.mjs';
|
|
20
20
|
import { executeMergeCmd } from './merge-cmd.mjs';
|
|
21
21
|
import { executeStatusCmd } from './status-cmd.mjs';
|
|
22
|
+
import { executeLogCmd } from './log-cmd.mjs';
|
|
22
23
|
import { logCheckpoint } from '../../test/test-helpers.mjs';
|
|
23
24
|
|
|
24
25
|
const lc = `[apps/vcs-gib/src/cli/commands/branch-checkout-cmd.respec.node.mts]`;
|
|
@@ -501,5 +502,58 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
|
|
|
501
502
|
await fs.rm(testDir, { recursive: true, force: true });
|
|
502
503
|
}
|
|
503
504
|
});
|
|
505
|
+
|
|
506
|
+
await ifWe(lc, `resolves contextual branch for log and status inside secondary branch worktree`, async () => {
|
|
507
|
+
const testDir = path.join(process.cwd(), '.test_contextual_worktree_branch');
|
|
508
|
+
const vcsFolderName = '.vcsgib_test_cwb';
|
|
509
|
+
try {
|
|
510
|
+
await executeInitCmd({ targetDir: testDir, vcsFolderName, quiet: true });
|
|
511
|
+
|
|
512
|
+
await fs.writeFile(path.join(testDir, 'app.ts'), 'console.log("main");\n', 'utf8');
|
|
513
|
+
await executeAddCmd({ paths: [path.join(testDir, 'app.ts')], targetDir: testDir, vcsFolderName, quiet: true });
|
|
514
|
+
await executeCommitCmd({ message: 'Main initial commit', targetDir: testDir, vcsFolderName, quiet: true });
|
|
515
|
+
|
|
516
|
+
// Create and switch to feature branch
|
|
517
|
+
await executeBranchCmd({
|
|
518
|
+
branchName: 'feature-calc',
|
|
519
|
+
targetDir: testDir,
|
|
520
|
+
vcsFolderName,
|
|
521
|
+
quiet: true,
|
|
522
|
+
});
|
|
523
|
+
const checkoutRes = await executeCheckoutCmd({
|
|
524
|
+
branchName: 'feature-calc',
|
|
525
|
+
targetDir: testDir,
|
|
526
|
+
vcsFolderName,
|
|
527
|
+
quiet: true,
|
|
528
|
+
});
|
|
529
|
+
const featureWorktree = checkoutRes.worktreePath;
|
|
530
|
+
iReckon(lc, featureWorktree).isGonnaBeTruthy();
|
|
531
|
+
|
|
532
|
+
// Commit on feature branch inside worktree
|
|
533
|
+
await fs.writeFile(path.join(featureWorktree!, 'calc.ts'), 'export const add = (a, b) => a + b;\n', 'utf8');
|
|
534
|
+
await executeAddCmd({ paths: [path.join(featureWorktree!, 'calc.ts')], targetDir: featureWorktree!, vcsFolderName, quiet: true });
|
|
535
|
+
await executeCommitCmd({ message: 'Add calc on feature-calc', targetDir: featureWorktree!, vcsFolderName, quiet: true });
|
|
536
|
+
|
|
537
|
+
// Checkout main again so index.activeBranch is 'main'
|
|
538
|
+
await executeCheckoutCmd({ branchName: 'main', targetDir: testDir, vcsFolderName, quiet: true });
|
|
539
|
+
|
|
540
|
+
// Now query log from inside featureWorktree
|
|
541
|
+
const featureLogRes = await executeLogCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
|
|
542
|
+
iReckon(lc, featureLogRes.branchName).willEqual('feature-calc');
|
|
543
|
+
const featureMessages = featureLogRes.commits.map(c => c.message);
|
|
544
|
+
iReckon(lc, featureMessages.some(m => m.includes('Add calc on feature-calc'))).isGonnaBeTrue();
|
|
545
|
+
|
|
546
|
+
// Query status from inside featureWorktree
|
|
547
|
+
const featureStatusRes = await executeStatusCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
|
|
548
|
+
iReckon(lc, featureStatusRes.branchName).willEqual('feature-calc');
|
|
549
|
+
|
|
550
|
+
// Query log from main repoRoot
|
|
551
|
+
const mainLogRes = await executeLogCmd({ targetDir: testDir, vcsFolderName, quiet: true });
|
|
552
|
+
iReckon(lc, mainLogRes.branchName).willEqual('main');
|
|
553
|
+
} finally {
|
|
554
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
555
|
+
}
|
|
556
|
+
});
|
|
504
557
|
});
|
|
505
558
|
|
|
559
|
+
|