@ibgib/vcs-gib 0.0.33 → 0.0.36
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 +5 -0
- package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
- package/dist/bootstrap/node-bootstrap.mjs +4 -0
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -1
- package/dist/cli/commands/cli-init-cmd.mjs +16 -1
- package/dist/cli/commands/cli-init-cmd.mjs.map +1 -1
- package/dist/cli/vcs-cli-main.d.mts.map +1 -1
- package/dist/cli/vcs-cli-main.mjs +22 -1
- package/dist/cli/vcs-cli-main.mjs.map +1 -1
- package/dist/cli/vcs-repo-helper.d.mts.map +1 -1
- package/dist/cli/vcs-repo-helper.mjs +16 -2
- package/dist/cli/vcs-repo-helper.mjs.map +1 -1
- package/package.json +6 -6
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/bootstrap/node-bootstrap.mts +10 -0
- package/src/cli/cli-e2e.respec.mts +127 -6
- package/src/cli/commands/branch-checkout-cmd.respec.mts +403 -403
- package/src/cli/commands/cli-init-cmd.mts +17 -1
- package/src/cli/commands/commit-log-cmd.respec.mts +5 -8
- package/src/cli/commands/status-add-cmd.respec.mts +7 -7
- package/src/cli/vcs-cli-main.mts +19 -1
- package/src/cli/vcs-repo-helper.mts +22 -3
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vcs-gib_test_output.md +43 -24
|
@@ -14,6 +14,7 @@ import { B2TFS_BRANCH_DEFAULT_NAME } from '@ibgib/core-gib/dist/vcs/branch/branc
|
|
|
14
14
|
|
|
15
15
|
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
16
16
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
17
|
+
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
17
18
|
import { writeVcsIndexProjectionToDisk } from '../vcs-projection-helper.mjs';
|
|
18
19
|
|
|
19
20
|
const lcFile = `[init-cmd]`;
|
|
@@ -46,12 +47,27 @@ export async function executeInitCmd({
|
|
|
46
47
|
await fs.mkdir(absTargetDir, { recursive: true });
|
|
47
48
|
|
|
48
49
|
// 2. Bootstrap Metaspace and localSpace (creates .vcsgib on disk)
|
|
49
|
-
const { metaspace, localSpace } = await bootstrapVcsMetaspace({
|
|
50
|
+
const { metaspace, localSpace, foundVcsPath } = await bootstrapVcsMetaspace({
|
|
50
51
|
repoPath: absTargetDir,
|
|
51
52
|
vcsFolderName,
|
|
52
53
|
defaultSpaceName: `vcs_${path.basename(absTargetDir).replace(/[^a-zA-Z0-9_\-]/g, '_')}`,
|
|
53
54
|
});
|
|
54
55
|
|
|
56
|
+
if (foundVcsPath) {
|
|
57
|
+
const existingIndex = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
|
|
58
|
+
if (existingIndex) {
|
|
59
|
+
if (!quiet) {
|
|
60
|
+
console.log(`Reinitialized existing ibgib repository in ${vcsPath}`);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
vcsPath,
|
|
64
|
+
spaceId: existingIndex.data.activeSpaceId,
|
|
65
|
+
branchName: existingIndex.data.activeBranchName || defaultBranchName,
|
|
66
|
+
rootItemIb: '',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
// 3. Facade instantiation and domain init
|
|
56
72
|
const repo = new VcsRepository({
|
|
57
73
|
metaspace,
|
|
@@ -30,7 +30,6 @@ import { executeCheckoutCmd } from './cli-checkout-cmd.mjs';
|
|
|
30
30
|
import { executeMergeCmd } from './cli-merge-cmd.mjs';
|
|
31
31
|
import { executeGenerateCommentCmd } from './cli-generate-comment-cmd.mjs';
|
|
32
32
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
33
|
-
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
34
33
|
|
|
35
34
|
const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.mts]`;
|
|
36
35
|
|
|
@@ -120,11 +119,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
120
119
|
quiet: true,
|
|
121
120
|
});
|
|
122
121
|
|
|
123
|
-
const {
|
|
122
|
+
const { metaspace: metaspaceAdd, localSpace: spaceAdd } = await bootstrapVcsMetaspace({
|
|
124
123
|
repoPath: testDir,
|
|
125
124
|
vcsFolderName,
|
|
126
125
|
});
|
|
127
|
-
const indexAdd = await
|
|
126
|
+
const indexAdd = await getB2tFSIndexIbGib({ space: spaceAdd, metaspace: metaspaceAdd });
|
|
128
127
|
iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
|
|
129
128
|
iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
130
129
|
|
|
@@ -135,11 +134,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
135
134
|
quiet: true,
|
|
136
135
|
});
|
|
137
136
|
|
|
138
|
-
const {
|
|
137
|
+
const { metaspace: metaspaceCommit, localSpace: spaceCommit } = await bootstrapVcsMetaspace({
|
|
139
138
|
repoPath: testDir,
|
|
140
139
|
vcsFolderName,
|
|
141
140
|
});
|
|
142
|
-
const indexCommit = await
|
|
141
|
+
const indexCommit = await getB2tFSIndexIbGib({ space: spaceCommit, metaspace: metaspaceCommit });
|
|
143
142
|
iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
|
|
144
143
|
iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
145
144
|
|
|
@@ -455,7 +454,6 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
455
454
|
|
|
456
455
|
const allMessages = mergedFileLog.commits.map(c => c.message).join(' -- ');
|
|
457
456
|
console.log(`allMessages: ${pretty(allMessages)}`);
|
|
458
|
-
iReckon(lc, allMessages).includes(`\n\n${pretty(allMessages)}\n\n`);
|
|
459
457
|
iReckon(lc, allMessages).includes('updated b to 200');
|
|
460
458
|
iReckon(lc, allMessages).includes('updated a to 100');
|
|
461
459
|
|
|
@@ -468,8 +466,7 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
468
466
|
metaspace,
|
|
469
467
|
branchName: 'main',
|
|
470
468
|
});
|
|
471
|
-
const indexIbGib =
|
|
472
|
-
|| (await readVcsIndexProjectionFromDisk({ space: localSpace, vcsPath }));
|
|
469
|
+
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
|
|
473
470
|
if (!indexIbGib) { throw new Error(`(UNEXPECTED) indexIbGib falsy? (E: d4ec1b6f86cbf18808fba957b7b83826)`); }
|
|
474
471
|
const branchAddrs_spacequalified = indexIbGib.data['$@branch'] ?? [];
|
|
475
472
|
if (branchAddrs_spacequalified.length === 0) {
|
|
@@ -24,7 +24,7 @@ const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.mts]`;
|
|
|
24
24
|
|
|
25
25
|
await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
26
26
|
|
|
27
|
-
await
|
|
27
|
+
await ifWe(lc, `detects untracked files in fresh repository`, async () => {
|
|
28
28
|
const testDir = path.join(process.cwd(), '.test_status_add_1');
|
|
29
29
|
const vcsFolderName = '.vcsgib_test_1';
|
|
30
30
|
try {
|
|
@@ -50,7 +50,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
await
|
|
53
|
+
await ifWe(lc, `discovers .vcsgib via upward discovery when executed from a subfolder`, async () => {
|
|
54
54
|
const testDir = path.join(process.cwd(), '.test_status_add_subfolder');
|
|
55
55
|
const vcsFolderName = '.vcsgib_test_subfolder';
|
|
56
56
|
try {
|
|
@@ -77,7 +77,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
await
|
|
80
|
+
await ifWe(lc, `skips re-staging unmodified committed files during executeAddCmd with all flag`, async () => {
|
|
81
81
|
const testDir = path.join(process.cwd(), '.test_status_add_unmodified');
|
|
82
82
|
const vcsFolderName = '.vcsgib_test_unmodified';
|
|
83
83
|
try {
|
|
@@ -118,7 +118,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
await
|
|
121
|
+
await ifWe(lc, `stages untracked file via executeAddCmd`, async () => {
|
|
122
122
|
const testDir = path.join(process.cwd(), '.test_status_add_2');
|
|
123
123
|
const vcsFolderName = '.vcsgib_test_2';
|
|
124
124
|
try {
|
|
@@ -162,7 +162,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
await
|
|
165
|
+
await ifWe(lc, `respects .ibgibignore patterns during status and add`, async () => {
|
|
166
166
|
const testDir = path.join(process.cwd(), '.test_status_add_3');
|
|
167
167
|
const vcsFolderName = '.vcsgib_test_3';
|
|
168
168
|
try {
|
|
@@ -203,7 +203,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
-
await
|
|
206
|
+
await ifWe(lc, `stages files matching glob pattern with executeAddCmd`, async () => {
|
|
207
207
|
const testDir = path.join(process.cwd(), '.test_status_add_glob');
|
|
208
208
|
const vcsFolderName = '.vcsgib_test_glob';
|
|
209
209
|
try {
|
|
@@ -246,7 +246,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
await
|
|
249
|
+
await ifWe(lc, `stages relative file paths correctly when targetDir is a subdirectory`, async () => {
|
|
250
250
|
const testDir = path.join(process.cwd(), '.test_status_add_subdir');
|
|
251
251
|
const vcsFolderName = '.vcsgib_test_subdir';
|
|
252
252
|
try {
|
package/src/cli/vcs-cli-main.mts
CHANGED
|
@@ -183,7 +183,25 @@ export async function main({
|
|
|
183
183
|
|
|
184
184
|
return 0;
|
|
185
185
|
} catch (error) {
|
|
186
|
-
|
|
186
|
+
let rawMsg = extractErrorMsg(error);
|
|
187
|
+
// Strip trailing internal UUID / error markers like (E: ...)
|
|
188
|
+
const cleanMsg = rawMsg.replace(/\s*\(E:\s*[a-f0-9-]+\)\s*$/i, '').trim();
|
|
189
|
+
|
|
190
|
+
if (cleanMsg.startsWith('fatal:') || cleanMsg.startsWith('error:')) {
|
|
191
|
+
console.error(cleanMsg);
|
|
192
|
+
} else if (cleanMsg.toLowerCase().includes('nothing to commit')) {
|
|
193
|
+
console.error('nothing to commit, working tree clean');
|
|
194
|
+
} else if (cleanMsg.toLowerCase().includes('already exists')) {
|
|
195
|
+
const branchMatch = cleanMsg.match(/["']([^"']+)["']/);
|
|
196
|
+
const name = branchMatch ? branchMatch[1] : '';
|
|
197
|
+
console.error(name ? `fatal: a branch named '${name}' already exists.` : `fatal: ${cleanMsg}`);
|
|
198
|
+
} else if (cleanMsg.toLowerCase().includes('not found in indexibgib') || cleanMsg.toLowerCase().includes('not found on branch')) {
|
|
199
|
+
const branchMatch = cleanMsg.match(/\(([^)]+)\)/) || cleanMsg.match(/['"]([^'"]+)['"]/);
|
|
200
|
+
const name = branchMatch ? branchMatch[1] : '';
|
|
201
|
+
console.error(name ? `error: pathspec '${name}' did not match any file(s) known to ibgib` : `error: ${cleanMsg}`);
|
|
202
|
+
} else {
|
|
203
|
+
console.error(`fatal: ${cleanMsg}`);
|
|
204
|
+
}
|
|
187
205
|
return 1;
|
|
188
206
|
} finally {
|
|
189
207
|
if (logalot) {
|
|
@@ -8,7 +8,7 @@ import path from 'node:path';
|
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
|
|
10
10
|
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
11
|
-
import { VcsRepository } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
|
|
11
|
+
import { VcsRepository, WorkspaceProjectionSpaceFactory } from '@ibgib/core-gib/dist/vcs/vcs-repository.mjs';
|
|
12
12
|
import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
13
13
|
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
14
14
|
import { getOrCreateBranchSpace } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
@@ -45,15 +45,20 @@ export async function openVcsRepository({
|
|
|
45
45
|
const absTargetDir = path.resolve(targetDir);
|
|
46
46
|
|
|
47
47
|
// 1. Locate repository root and bootstrap Node localSpace
|
|
48
|
-
const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
|
|
48
|
+
const { metaspace, localSpace, vcsPath, repoRoot, foundVcsPath } = await bootstrapVcsMetaspace({
|
|
49
49
|
repoPath: absTargetDir,
|
|
50
50
|
vcsFolderName,
|
|
51
|
+
mustExist: true,
|
|
51
52
|
});
|
|
52
53
|
|
|
54
|
+
if (!foundVcsPath) {
|
|
55
|
+
throw new Error(`fatal: not an ibgib repository (or any of the parent directories): ${vcsFolderName}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
// 2. Fetch authoritative in-band index from localSpace
|
|
54
59
|
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
|
|
55
60
|
if (!indexIbGib) {
|
|
56
|
-
throw new Error(`
|
|
61
|
+
throw new Error(`fatal: not an ibgib repository (index not found in ${vcsPath})`);
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
// 3. Determine active branch and worktree directory
|
|
@@ -80,11 +85,25 @@ export async function openVcsRepository({
|
|
|
80
85
|
backingSpace: activeSpace,
|
|
81
86
|
});
|
|
82
87
|
|
|
88
|
+
const fnGetWorkspaceProjectionSpace: WorkspaceProjectionSpaceFactory = async ({
|
|
89
|
+
worktreeDir,
|
|
90
|
+
backingSpace,
|
|
91
|
+
}) => {
|
|
92
|
+
const { space } = await getOrCreateWorkspaceProjectionSpace({
|
|
93
|
+
metaspace,
|
|
94
|
+
workspaceRoot: worktreeDir,
|
|
95
|
+
vcsFolderName,
|
|
96
|
+
backingSpace,
|
|
97
|
+
});
|
|
98
|
+
return space;
|
|
99
|
+
};
|
|
100
|
+
|
|
83
101
|
// 5. Construct domain facade
|
|
84
102
|
const repo = new VcsRepository({
|
|
85
103
|
metaspace,
|
|
86
104
|
localSpace,
|
|
87
105
|
workspaceSpace,
|
|
106
|
+
fnGetWorkspaceProjectionSpace,
|
|
88
107
|
repoRoot,
|
|
89
108
|
vcsFolderName,
|
|
90
109
|
});
|