@ibgib/vcs-gib 0.0.6
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 +94 -0
- package/VCS_CLI_USER_GUIDE.md +198 -0
- package/dist/AUTO-GENERATED-version.d.mts +6 -0
- package/dist/AUTO-GENERATED-version.d.mts.map +1 -0
- package/dist/AUTO-GENERATED-version.mjs +6 -0
- package/dist/AUTO-GENERATED-version.mjs.map +1 -0
- package/dist/assumptions.respec.d.mts +2 -0
- package/dist/assumptions.respec.d.mts.map +1 -0
- package/dist/assumptions.respec.mjs +41 -0
- package/dist/assumptions.respec.mjs.map +1 -0
- package/dist/bootstrap/node-bootstrap.d.mts +35 -0
- package/dist/bootstrap/node-bootstrap.d.mts.map +1 -0
- package/dist/bootstrap/node-bootstrap.mjs +165 -0
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -0
- package/dist/bootstrap/node-bootstrap.respec.node.d.mts +7 -0
- package/dist/bootstrap/node-bootstrap.respec.node.d.mts.map +1 -0
- package/dist/bootstrap/node-bootstrap.respec.node.mjs +28 -0
- package/dist/bootstrap/node-bootstrap.respec.node.mjs.map +1 -0
- package/dist/cli/cli-arg-parser.d.mts +27 -0
- package/dist/cli/cli-arg-parser.d.mts.map +1 -0
- package/dist/cli/cli-arg-parser.mjs +96 -0
- package/dist/cli/cli-arg-parser.mjs.map +1 -0
- package/dist/cli/cli-arg-parser.respec.node.d.mts +7 -0
- package/dist/cli/cli-arg-parser.respec.node.d.mts.map +1 -0
- package/dist/cli/cli-arg-parser.respec.node.mjs +35 -0
- package/dist/cli/cli-arg-parser.respec.node.mjs.map +1 -0
- package/dist/cli/cli-constants.d.mts +26 -0
- package/dist/cli/cli-constants.d.mts.map +1 -0
- package/dist/cli/cli-constants.mjs +67 -0
- package/dist/cli/cli-constants.mjs.map +1 -0
- package/dist/cli/cli-e2e.respec.node.d.mts +8 -0
- package/dist/cli/cli-e2e.respec.node.d.mts.map +1 -0
- package/dist/cli/cli-e2e.respec.node.mjs +263 -0
- package/dist/cli/cli-e2e.respec.node.mjs.map +1 -0
- package/dist/cli/commands/add-cmd.d.mts +20 -0
- package/dist/cli/commands/add-cmd.d.mts.map +1 -0
- package/dist/cli/commands/add-cmd.mjs +333 -0
- package/dist/cli/commands/add-cmd.mjs.map +1 -0
- package/dist/cli/commands/branch-checkout-cmd.respec.node.d.mts +7 -0
- package/dist/cli/commands/branch-checkout-cmd.respec.node.d.mts.map +1 -0
- package/dist/cli/commands/branch-checkout-cmd.respec.node.mjs +288 -0
- package/dist/cli/commands/branch-checkout-cmd.respec.node.mjs.map +1 -0
- package/dist/cli/commands/branch-cmd.d.mts +25 -0
- package/dist/cli/commands/branch-cmd.d.mts.map +1 -0
- package/dist/cli/commands/branch-cmd.mjs +187 -0
- package/dist/cli/commands/branch-cmd.mjs.map +1 -0
- package/dist/cli/commands/checkout-cmd.d.mts +21 -0
- package/dist/cli/commands/checkout-cmd.d.mts.map +1 -0
- package/dist/cli/commands/checkout-cmd.mjs +154 -0
- package/dist/cli/commands/checkout-cmd.mjs.map +1 -0
- package/dist/cli/commands/commit-cmd.d.mts +23 -0
- package/dist/cli/commands/commit-cmd.d.mts.map +1 -0
- package/dist/cli/commands/commit-cmd.mjs +326 -0
- package/dist/cli/commands/commit-cmd.mjs.map +1 -0
- package/dist/cli/commands/commit-log-cmd.respec.node.d.mts +7 -0
- package/dist/cli/commands/commit-log-cmd.respec.node.d.mts.map +1 -0
- package/dist/cli/commands/commit-log-cmd.respec.node.mjs +251 -0
- package/dist/cli/commands/commit-log-cmd.respec.node.mjs.map +1 -0
- package/dist/cli/commands/init-cmd.d.mts +20 -0
- package/dist/cli/commands/init-cmd.d.mts.map +1 -0
- package/dist/cli/commands/init-cmd.mjs +119 -0
- package/dist/cli/commands/init-cmd.mjs.map +1 -0
- package/dist/cli/commands/init-cmd.respec.node.d.mts +7 -0
- package/dist/cli/commands/init-cmd.respec.node.d.mts.map +1 -0
- package/dist/cli/commands/init-cmd.respec.node.mjs +40 -0
- package/dist/cli/commands/init-cmd.respec.node.mjs.map +1 -0
- package/dist/cli/commands/log-cmd.d.mts +27 -0
- package/dist/cli/commands/log-cmd.d.mts.map +1 -0
- package/dist/cli/commands/log-cmd.mjs +146 -0
- package/dist/cli/commands/log-cmd.mjs.map +1 -0
- package/dist/cli/commands/status-add-cmd.respec.node.d.mts +7 -0
- package/dist/cli/commands/status-add-cmd.respec.node.d.mts.map +1 -0
- package/dist/cli/commands/status-add-cmd.respec.node.mjs +215 -0
- package/dist/cli/commands/status-add-cmd.respec.node.mjs.map +1 -0
- package/dist/cli/commands/status-cmd.d.mts +25 -0
- package/dist/cli/commands/status-cmd.d.mts.map +1 -0
- package/dist/cli/commands/status-cmd.mjs +286 -0
- package/dist/cli/commands/status-cmd.mjs.map +1 -0
- package/dist/cli/vcs-cli-main.d.mts +14 -0
- package/dist/cli/vcs-cli-main.d.mts.map +1 -0
- package/dist/cli/vcs-cli-main.mjs +136 -0
- package/dist/cli/vcs-cli-main.mjs.map +1 -0
- package/dist/engine/branch/branch-graph-helper.d.mts +19 -0
- package/dist/engine/branch/branch-graph-helper.d.mts.map +1 -0
- package/dist/engine/branch/branch-graph-helper.mjs +49 -0
- package/dist/engine/branch/branch-graph-helper.mjs.map +1 -0
- package/dist/engine/branch/branch-helper.d.mts +26 -0
- package/dist/engine/branch/branch-helper.d.mts.map +1 -0
- package/dist/engine/branch/branch-helper.mjs +57 -0
- package/dist/engine/branch/branch-helper.mjs.map +1 -0
- package/dist/engine/branch/branch-space-helper.d.mts +22 -0
- package/dist/engine/branch/branch-space-helper.d.mts.map +1 -0
- package/dist/engine/branch/branch-space-helper.mjs +77 -0
- package/dist/engine/branch/branch-space-helper.mjs.map +1 -0
- package/dist/engine/branch/branch-space.respec.node.d.mts +8 -0
- package/dist/engine/branch/branch-space.respec.node.d.mts.map +1 -0
- package/dist/engine/branch/branch-space.respec.node.mjs +138 -0
- package/dist/engine/branch/branch-space.respec.node.mjs.map +1 -0
- package/dist/engine/branch/branch-types.d.mts +26 -0
- package/dist/engine/branch/branch-types.d.mts.map +1 -0
- package/dist/engine/branch/branch-types.mjs +7 -0
- package/dist/engine/branch/branch-types.mjs.map +1 -0
- package/dist/engine/diff/line-diff-helper.d.mts +76 -0
- package/dist/engine/diff/line-diff-helper.d.mts.map +1 -0
- package/dist/engine/diff/line-diff-helper.mjs +144 -0
- package/dist/engine/diff/line-diff-helper.mjs.map +1 -0
- package/dist/engine/diff/line-diff-helper.respec.node.d.mts +7 -0
- package/dist/engine/diff/line-diff-helper.respec.node.d.mts.map +1 -0
- package/dist/engine/diff/line-diff-helper.respec.node.mjs +66 -0
- package/dist/engine/diff/line-diff-helper.respec.node.mjs.map +1 -0
- package/dist/engine/filter/glob-helper.d.mts +51 -0
- package/dist/engine/filter/glob-helper.d.mts.map +1 -0
- package/dist/engine/filter/glob-helper.mjs +132 -0
- package/dist/engine/filter/glob-helper.mjs.map +1 -0
- package/dist/engine/filter/glob-helper.respec.node.d.mts +7 -0
- package/dist/engine/filter/glob-helper.respec.node.d.mts.map +1 -0
- package/dist/engine/filter/glob-helper.respec.node.mjs +78 -0
- package/dist/engine/filter/glob-helper.respec.node.mjs.map +1 -0
- package/dist/engine/index/index-helper.d.mts +78 -0
- package/dist/engine/index/index-helper.d.mts.map +1 -0
- package/dist/engine/index/index-helper.mjs +289 -0
- package/dist/engine/index/index-helper.mjs.map +1 -0
- package/dist/engine/index/index-types.d.mts +63 -0
- package/dist/engine/index/index-types.d.mts.map +1 -0
- package/dist/engine/index/index-types.mjs +7 -0
- package/dist/engine/index/index-types.mjs.map +1 -0
- package/dist/engine/item/item-atom-helper.d.mts +20 -0
- package/dist/engine/item/item-atom-helper.d.mts.map +1 -0
- package/dist/engine/item/item-atom-helper.mjs +30 -0
- package/dist/engine/item/item-atom-helper.mjs.map +1 -0
- package/dist/engine/item/item-helper.d.mts +37 -0
- package/dist/engine/item/item-helper.d.mts.map +1 -0
- package/dist/engine/item/item-helper.mjs +194 -0
- package/dist/engine/item/item-helper.mjs.map +1 -0
- package/dist/engine/item/item-types.d.mts +127 -0
- package/dist/engine/item/item-types.d.mts.map +1 -0
- package/dist/engine/item/item-types.mjs +16 -0
- package/dist/engine/item/item-types.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/respec-gib.node.d.mts +7 -0
- package/dist/respec-gib.node.d.mts.map +1 -0
- package/dist/respec-gib.node.mjs +11 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/dist/vcs-gib-constants.d.mts +7 -0
- package/dist/vcs-gib-constants.d.mts.map +1 -0
- package/dist/vcs-gib-constants.mjs +7 -0
- package/dist/vcs-gib-constants.mjs.map +1 -0
- package/dist/vcs-gib.respec.node.d.mts +8 -0
- package/dist/vcs-gib.respec.node.d.mts.map +1 -0
- package/dist/vcs-gib.respec.node.mjs +82 -0
- package/dist/vcs-gib.respec.node.mjs.map +1 -0
- package/generate-version-file.js +20 -0
- package/package.json +28 -0
- package/src/AUTO-GENERATED-version.mts +5 -0
- package/src/assumptions.respec.mts +50 -0
- package/src/bootstrap/node-bootstrap.mts +198 -0
- package/src/bootstrap/node-bootstrap.respec.node.mts +35 -0
- package/src/cli/cli-arg-parser.mts +119 -0
- package/src/cli/cli-arg-parser.respec.node.mts +45 -0
- package/src/cli/cli-constants.mts +77 -0
- package/src/cli/cli-e2e.respec.node.mts +318 -0
- package/src/cli/commands/add-cmd.mts +415 -0
- package/src/cli/commands/branch-checkout-cmd.respec.node.mts +322 -0
- package/src/cli/commands/branch-cmd.mts +243 -0
- package/src/cli/commands/checkout-cmd.mts +202 -0
- package/src/cli/commands/commit-cmd.mts +421 -0
- package/src/cli/commands/commit-log-cmd.respec.node.mts +276 -0
- package/src/cli/commands/init-cmd.mts +152 -0
- package/src/cli/commands/init-cmd.respec.node.mts +49 -0
- package/src/cli/commands/log-cmd.mts +197 -0
- package/src/cli/commands/status-add-cmd.respec.node.mts +246 -0
- package/src/cli/commands/status-cmd.mts +366 -0
- package/src/cli/vcs-cli-main.mts +153 -0
- package/src/engine/branch/branch-graph-helper.mts +69 -0
- package/src/engine/branch/branch-helper.mts +79 -0
- package/src/engine/branch/branch-space-helper.mts +104 -0
- package/src/engine/branch/branch-space.respec.node.mts +158 -0
- package/src/engine/branch/branch-types.mts +29 -0
- package/src/engine/diff/line-diff-helper.mts +210 -0
- package/src/engine/diff/line-diff-helper.respec.node.mts +84 -0
- package/src/engine/filter/glob-helper.mts +165 -0
- package/src/engine/filter/glob-helper.respec.node.mts +94 -0
- package/src/engine/index/index-helper.mts +378 -0
- package/src/engine/index/index-types.mts +66 -0
- package/src/engine/item/item-atom-helper.mts +30 -0
- package/src/engine/item/item-helper.mts +239 -0
- package/src/engine/item/item-types.mts +136 -0
- package/src/index.mts +7 -0
- package/src/respec-gib.node.mts +12 -0
- package/src/vcs-gib-constants.mts +7 -0
- package/src/vcs-gib.respec.node.mts +96 -0
- package/test_runs/001-hello-node/20260728_090100_0001-flow-core-main.md +39 -0
- package/test_runs/001-hello-node/20260728_090200_0003-flow-branching-worktree.md +54 -0
- package/test_runs/001-hello-node/20260728_090300_0002-flow-selective-add.md +45 -0
- package/test_runs/001-hello-node/20260728_142100_0007-flow-edge-cases.md +44 -0
- package/test_runs/001-hello-node/20260728_142400_0005-flow-hardcoded-ignores.md +36 -0
- package/tools/pack-for-test.mjs +73 -0
- package/tsconfig.json +18 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module commit-log-cmd.respec
|
|
3
|
+
*
|
|
4
|
+
* Unit tests for `vcs commit` and `vcs log` command handlers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
respecfully, ifWe, iReckon
|
|
12
|
+
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
13
|
+
|
|
14
|
+
import { executeInitCmd } from './init-cmd.mjs';
|
|
15
|
+
import { executeAddCmd } from './add-cmd.mjs';
|
|
16
|
+
import { executeStatusCmd } from './status-cmd.mjs';
|
|
17
|
+
import { executeCommitCmd } from './commit-cmd.mjs';
|
|
18
|
+
import { executeLogCmd } from './log-cmd.mjs';
|
|
19
|
+
import { executeBranchCmd } from './branch-cmd.mjs';
|
|
20
|
+
import { executeCheckoutCmd } from './checkout-cmd.mjs';
|
|
21
|
+
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
22
|
+
import { getB2tFSIndexIbGib } from '../../engine/index/index-helper.mjs';
|
|
23
|
+
|
|
24
|
+
const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.node.mts]`;
|
|
25
|
+
|
|
26
|
+
await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
27
|
+
|
|
28
|
+
await ifWe(lc, `rejects commit when no message is provided`, async () => {
|
|
29
|
+
const testDir = path.join(process.cwd(), '.test_commit_log_1');
|
|
30
|
+
const vcsFolderName = '.vcsgib_test_commit_1';
|
|
31
|
+
try {
|
|
32
|
+
await executeInitCmd({
|
|
33
|
+
targetDir: testDir,
|
|
34
|
+
vcsFolderName,
|
|
35
|
+
quiet: true,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await fs.writeFile(path.join(testDir, 'file1.txt'), 'Hello Commit', 'utf8');
|
|
39
|
+
await executeAddCmd({
|
|
40
|
+
paths: ['file1.txt'],
|
|
41
|
+
targetDir: testDir,
|
|
42
|
+
vcsFolderName,
|
|
43
|
+
quiet: true,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
let errorThrown = false;
|
|
47
|
+
try {
|
|
48
|
+
await executeCommitCmd({
|
|
49
|
+
message: '',
|
|
50
|
+
targetDir: testDir,
|
|
51
|
+
vcsFolderName,
|
|
52
|
+
quiet: true,
|
|
53
|
+
});
|
|
54
|
+
} catch (err: any) {
|
|
55
|
+
errorThrown = true;
|
|
56
|
+
iReckon(lc, err.message).includes('Commit message is required');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
iReckon(lc, errorThrown).isGonnaBeTrue();
|
|
60
|
+
} finally {
|
|
61
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await ifWe(lc, `rejects commit when no items are staged`, async () => {
|
|
66
|
+
const testDir = path.join(process.cwd(), '.test_commit_log_2');
|
|
67
|
+
const vcsFolderName = '.vcsgib_test_commit_2';
|
|
68
|
+
try {
|
|
69
|
+
await executeInitCmd({
|
|
70
|
+
targetDir: testDir,
|
|
71
|
+
vcsFolderName,
|
|
72
|
+
quiet: true,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
let errorThrown = false;
|
|
76
|
+
try {
|
|
77
|
+
await executeCommitCmd({
|
|
78
|
+
message: 'Empty commit',
|
|
79
|
+
targetDir: testDir,
|
|
80
|
+
vcsFolderName,
|
|
81
|
+
quiet: true,
|
|
82
|
+
});
|
|
83
|
+
} catch (err: any) {
|
|
84
|
+
errorThrown = true;
|
|
85
|
+
iReckon(lc, err.message).includes('Nothing to commit');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
iReckon(lc, errorThrown).isGonnaBeTrue();
|
|
89
|
+
} finally {
|
|
90
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await ifWe(lc, `commits staged files and advances active branch tip`, async () => {
|
|
95
|
+
const testDir = path.join(process.cwd(), '.test_commit_log_3');
|
|
96
|
+
const vcsFolderName = '.vcsgib_test_commit_3';
|
|
97
|
+
try {
|
|
98
|
+
await executeInitCmd({
|
|
99
|
+
targetDir: testDir,
|
|
100
|
+
vcsFolderName,
|
|
101
|
+
quiet: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
await fs.writeFile(path.join(testDir, 'hello.txt'), 'Hello ibgib repository!', 'utf8');
|
|
105
|
+
await executeAddCmd({
|
|
106
|
+
paths: ['hello.txt'],
|
|
107
|
+
targetDir: testDir,
|
|
108
|
+
vcsFolderName,
|
|
109
|
+
quiet: true,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const { localSpace: spaceAdd, vcsPath: vcsPathAdd } = await bootstrapVcsMetaspace({
|
|
113
|
+
repoPath: testDir,
|
|
114
|
+
vcsFolderName,
|
|
115
|
+
});
|
|
116
|
+
const indexAdd = await getB2tFSIndexIbGib({ space: spaceAdd, vcsPath: vcsPathAdd });
|
|
117
|
+
iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
|
|
118
|
+
iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
119
|
+
|
|
120
|
+
const commitRes = await executeCommitCmd({
|
|
121
|
+
message: 'Initial repository commit',
|
|
122
|
+
targetDir: testDir,
|
|
123
|
+
vcsFolderName,
|
|
124
|
+
quiet: true,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const { localSpace: spaceCommit, vcsPath: vcsPathCommit } = await bootstrapVcsMetaspace({
|
|
128
|
+
repoPath: testDir,
|
|
129
|
+
vcsFolderName,
|
|
130
|
+
});
|
|
131
|
+
const indexCommit = await getB2tFSIndexIbGib({ space: spaceCommit, vcsPath: vcsPathCommit });
|
|
132
|
+
iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
|
|
133
|
+
iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
134
|
+
|
|
135
|
+
iReckon(lc, commitRes.branchName).willEqual('main');
|
|
136
|
+
iReckon(lc, commitRes.committedPaths).includes('hello.txt');
|
|
137
|
+
iReckon(lc, Boolean(commitRes.commitAddr)).isGonnaBeTrue();
|
|
138
|
+
iReckon(lc, Boolean(commitRes.commentAddr)).isGonnaBeTrue();
|
|
139
|
+
|
|
140
|
+
const statusRes = await executeStatusCmd({
|
|
141
|
+
targetDir: testDir,
|
|
142
|
+
vcsFolderName,
|
|
143
|
+
quiet: true,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
iReckon(lc, statusRes.staged.length).willEqual(0);
|
|
147
|
+
iReckon(lc, statusRes.modified.length).willEqual(0);
|
|
148
|
+
iReckon(lc, statusRes.untracked.length).willEqual(0);
|
|
149
|
+
} finally {
|
|
150
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
await ifWe(lc, `displays formatted commit history with executeLogCmd across multiple commits`, async () => {
|
|
155
|
+
const testDir = path.join(process.cwd(), '.test_commit_log_4');
|
|
156
|
+
const vcsFolderName = '.vcsgib_test_commit_4';
|
|
157
|
+
try {
|
|
158
|
+
await executeInitCmd({
|
|
159
|
+
targetDir: testDir,
|
|
160
|
+
vcsFolderName,
|
|
161
|
+
quiet: true,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Commit 1
|
|
165
|
+
await fs.writeFile(path.join(testDir, 'file1.txt'), 'Version 1', 'utf8');
|
|
166
|
+
await executeAddCmd({
|
|
167
|
+
paths: ['file1.txt'],
|
|
168
|
+
targetDir: testDir,
|
|
169
|
+
vcsFolderName,
|
|
170
|
+
quiet: true,
|
|
171
|
+
});
|
|
172
|
+
await executeCommitCmd({
|
|
173
|
+
message: 'First commit message',
|
|
174
|
+
targetDir: testDir,
|
|
175
|
+
vcsFolderName,
|
|
176
|
+
quiet: true,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Commit 2
|
|
180
|
+
await fs.writeFile(path.join(testDir, 'file2.txt'), 'Version 2', 'utf8');
|
|
181
|
+
await executeAddCmd({
|
|
182
|
+
paths: ['file2.txt'],
|
|
183
|
+
targetDir: testDir,
|
|
184
|
+
vcsFolderName,
|
|
185
|
+
quiet: true,
|
|
186
|
+
});
|
|
187
|
+
await executeCommitCmd({
|
|
188
|
+
message: 'Second commit message',
|
|
189
|
+
targetDir: testDir,
|
|
190
|
+
vcsFolderName,
|
|
191
|
+
quiet: true,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const logRes = await executeLogCmd({
|
|
195
|
+
targetDir: testDir,
|
|
196
|
+
vcsFolderName,
|
|
197
|
+
quiet: true,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
iReckon(lc, logRes.branchName).willEqual('main');
|
|
201
|
+
iReckon(lc, logRes.commits.length).willEqual(2);
|
|
202
|
+
iReckon(lc, logRes.commits[0].message).willEqual('Second commit message');
|
|
203
|
+
iReckon(lc, logRes.commits[1].message).willEqual('First commit message');
|
|
204
|
+
} finally {
|
|
205
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
await ifWe(lc, `walks feature branch commits with executeLogCmd on active feature branch`, async () => {
|
|
210
|
+
const testDir = path.join(process.cwd(), '.test_commit_log_feature');
|
|
211
|
+
const vcsFolderName = '.vcsgib_test_commit_feature';
|
|
212
|
+
try {
|
|
213
|
+
await executeInitCmd({
|
|
214
|
+
targetDir: testDir,
|
|
215
|
+
vcsFolderName,
|
|
216
|
+
quiet: true,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Commit on main
|
|
220
|
+
await fs.writeFile(path.join(testDir, 'main.txt'), 'Main branch content', 'utf8');
|
|
221
|
+
await executeAddCmd({
|
|
222
|
+
paths: ['main.txt'],
|
|
223
|
+
targetDir: testDir,
|
|
224
|
+
vcsFolderName,
|
|
225
|
+
quiet: true,
|
|
226
|
+
});
|
|
227
|
+
await executeCommitCmd({
|
|
228
|
+
message: 'Main branch commit',
|
|
229
|
+
targetDir: testDir,
|
|
230
|
+
vcsFolderName,
|
|
231
|
+
quiet: true,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Create and checkout feature branch
|
|
235
|
+
await executeBranchCmd({
|
|
236
|
+
branchName: 'feature-log',
|
|
237
|
+
targetDir: testDir,
|
|
238
|
+
vcsFolderName,
|
|
239
|
+
quiet: true,
|
|
240
|
+
});
|
|
241
|
+
const checkoutRes = await executeCheckoutCmd({
|
|
242
|
+
branchName: 'feature-log',
|
|
243
|
+
targetDir: testDir,
|
|
244
|
+
vcsFolderName,
|
|
245
|
+
quiet: true,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Commit on feature branch
|
|
249
|
+
await fs.writeFile(path.join(checkoutRes.worktreePath, 'feature.txt'), 'Feature branch content', 'utf8');
|
|
250
|
+
await executeAddCmd({
|
|
251
|
+
paths: ['feature.txt'],
|
|
252
|
+
targetDir: checkoutRes.worktreePath,
|
|
253
|
+
vcsFolderName,
|
|
254
|
+
quiet: true,
|
|
255
|
+
});
|
|
256
|
+
await executeCommitCmd({
|
|
257
|
+
message: 'Feature branch commit',
|
|
258
|
+
targetDir: checkoutRes.worktreePath,
|
|
259
|
+
vcsFolderName,
|
|
260
|
+
quiet: true,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const logRes = await executeLogCmd({
|
|
264
|
+
targetDir: checkoutRes.worktreePath,
|
|
265
|
+
vcsFolderName,
|
|
266
|
+
quiet: true,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
iReckon(lc, logRes.branchName).willEqual('feature-log');
|
|
270
|
+
iReckon(lc, logRes.commits.length).willEqual(1);
|
|
271
|
+
iReckon(lc, logRes.commits[0].message).willEqual('Feature branch commit');
|
|
272
|
+
} finally {
|
|
273
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module init-cmd
|
|
3
|
+
*
|
|
4
|
+
* Command handler for `vcs init [targetDir]`.
|
|
5
|
+
* Initializes local repository space, root B2tFS folder item, default branch, and in-band space index.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
|
+
|
|
11
|
+
import { extractErrorMsg, getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
13
|
+
import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
14
|
+
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
15
|
+
import { putInSpace, persistTransformResult } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
16
|
+
|
|
17
|
+
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
18
|
+
import { getB2tFSItemIb } from '../../engine/item/item-atom-helper.mjs';
|
|
19
|
+
import { B2tFSItemIbGib_V1 } from '../../engine/item/item-types.mjs';
|
|
20
|
+
import { createB2tFSBranchIbGib, getB2tFSBranchSpaceName } from '../../engine/branch/branch-helper.mjs';
|
|
21
|
+
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
22
|
+
import { createB2tFSIndexIbGib, writeVcsIndexProjection } from '../../engine/index/index-helper.mjs';
|
|
23
|
+
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
24
|
+
|
|
25
|
+
const lcFile = `[init-cmd]`;
|
|
26
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
27
|
+
|
|
28
|
+
export interface InitCmdOpts {
|
|
29
|
+
targetDir?: string;
|
|
30
|
+
vcsFolderName?: string;
|
|
31
|
+
defaultBranchName?: string;
|
|
32
|
+
quiet?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface InitCmdResult {
|
|
36
|
+
vcsPath: string;
|
|
37
|
+
spaceId: string;
|
|
38
|
+
branchName: string;
|
|
39
|
+
rootItemIb: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function executeInitCmd({
|
|
43
|
+
targetDir = process.cwd(),
|
|
44
|
+
vcsFolderName = '.vcsgib',
|
|
45
|
+
defaultBranchName = 'main',
|
|
46
|
+
quiet = false,
|
|
47
|
+
}: InitCmdOpts = {}): Promise<InitCmdResult> {
|
|
48
|
+
const lc = `${lcFile}[${executeInitCmd.name}]`;
|
|
49
|
+
try {
|
|
50
|
+
if (logalot) {
|
|
51
|
+
console.log(`${lc} starting... (I: 8a9b10c11d12e13f14a15b16c17d18e1)`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const absTargetDir = path.resolve(targetDir);
|
|
55
|
+
const vcsPath = path.join(absTargetDir, vcsFolderName);
|
|
56
|
+
|
|
57
|
+
// Create target repository folder if it doesn't exist
|
|
58
|
+
await fs.mkdir(absTargetDir, { recursive: true });
|
|
59
|
+
|
|
60
|
+
// Bootstrap Metaspace
|
|
61
|
+
const { metaspace } = await bootstrapVcsMetaspace({
|
|
62
|
+
repoPath: absTargetDir,
|
|
63
|
+
vcsFolderName,
|
|
64
|
+
defaultSpaceName: `vcs_${path.basename(absTargetDir).replace(/[^a-zA-Z0-9_\-]/g, '_')}`,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Initialize b2s_main branch space
|
|
68
|
+
const { space: branchSpace, spaceId } = await getOrCreateBranchSpace({
|
|
69
|
+
metaspace,
|
|
70
|
+
vcsPath,
|
|
71
|
+
branchName: defaultBranchName,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const folderName = path.basename(absTargetDir) || 'root';
|
|
75
|
+
const rootNameHash = await getUUID();
|
|
76
|
+
|
|
77
|
+
// 1. Create root folder B2tFS item inside b2s_main space
|
|
78
|
+
const rootItemRes = await Factory_V1.firstGen({
|
|
79
|
+
parentIbGib: ROOT,
|
|
80
|
+
ib: getB2tFSItemIb('folder', folderName, rootNameHash),
|
|
81
|
+
data: {
|
|
82
|
+
name: folderName,
|
|
83
|
+
nameHash: rootNameHash,
|
|
84
|
+
fsType: 'folder',
|
|
85
|
+
diffTransactionId: await getUUID(),
|
|
86
|
+
uuid: await getUUID(),
|
|
87
|
+
classname: 'B2tFSItemIbGib_V1',
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const rootItem = rootItemRes.newIbGib as B2tFSItemIbGib_V1;
|
|
92
|
+
await persistTransformResult({ resTransform: rootItemRes, space: branchSpace });
|
|
93
|
+
await metaspace.registerNewIbGib({ ibGib: rootItem, space: branchSpace });
|
|
94
|
+
|
|
95
|
+
// 2. Create default branch pointing to root folder inside b2s_main space
|
|
96
|
+
const branchIbGib = await createB2tFSBranchIbGib({
|
|
97
|
+
branchName: defaultBranchName,
|
|
98
|
+
rootItem,
|
|
99
|
+
space: branchSpace,
|
|
100
|
+
metaspace,
|
|
101
|
+
});
|
|
102
|
+
const branchAddr = getIbGibAddr({ ibGib: branchIbGib });
|
|
103
|
+
|
|
104
|
+
// 3. Create space index meta object stored inside b2s_main space
|
|
105
|
+
const indexIbGib = await createB2tFSIndexIbGib({
|
|
106
|
+
spaceId,
|
|
107
|
+
activeSpaceId: getB2tFSBranchSpaceName(defaultBranchName),
|
|
108
|
+
activeBranch: defaultBranchName,
|
|
109
|
+
space: branchSpace,
|
|
110
|
+
metaspace,
|
|
111
|
+
branchAddr,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// 4. Write read-only projection file in .vcsgib/
|
|
115
|
+
await writeVcsIndexProjection({
|
|
116
|
+
vcsPath,
|
|
117
|
+
indexIbGib,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Clean up legacy out-of-band state files if present
|
|
121
|
+
try {
|
|
122
|
+
await fs.rm(path.join(vcsPath, 'vcs_state.json'), { force: true });
|
|
123
|
+
} catch {
|
|
124
|
+
// Ignore if missing
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
await fs.rm(path.join(vcsPath, 'staging.json'), { force: true });
|
|
128
|
+
} catch {
|
|
129
|
+
// Ignore if missing
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!quiet) {
|
|
133
|
+
console.log(`Initialized empty ibgib repository in ${vcsPath} (I: 6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f)`);
|
|
134
|
+
console.log(` Branch: ${defaultBranchName}`);
|
|
135
|
+
console.log(` Root Item: ${rootItem.ib}`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
vcsPath,
|
|
140
|
+
spaceId,
|
|
141
|
+
branchName: defaultBranchName,
|
|
142
|
+
rootItemIb: rootItem.ib,
|
|
143
|
+
};
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: 9b10c11d12e13f14a15b16c17d18e19f)`);
|
|
146
|
+
throw error;
|
|
147
|
+
} finally {
|
|
148
|
+
if (logalot) {
|
|
149
|
+
console.log(`${lc} complete. (I: 0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d)`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module init-cmd.respec
|
|
3
|
+
*
|
|
4
|
+
* Unit tests for `vcs init` command handler.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
respecfully, ifWe, iReckon
|
|
13
|
+
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
14
|
+
|
|
15
|
+
import { executeInitCmd } from './init-cmd.mjs';
|
|
16
|
+
|
|
17
|
+
const lc = `[apps/vcs-gib/src/cli/commands/init-cmd.respec.node.mts]`;
|
|
18
|
+
|
|
19
|
+
await respecfully(lc, `vcs init Command Handler`, async () => {
|
|
20
|
+
|
|
21
|
+
await ifWe(lc, `initializes repository space, branch, and index in target folder`, async () => {
|
|
22
|
+
const testDir = path.join(process.cwd(), '.test_init_repo');
|
|
23
|
+
const vcsFolderName = '.vcsgib_init_test';
|
|
24
|
+
try {
|
|
25
|
+
const res = await executeInitCmd({
|
|
26
|
+
targetDir: testDir,
|
|
27
|
+
vcsFolderName,
|
|
28
|
+
quiet: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
iReckon(lc, res.branchName).willEqual('main');
|
|
32
|
+
iReckon(lc, res.rootItemIb).includes('b2tfs_item folder');
|
|
33
|
+
iReckon(lc, res.vcsPath).includes(vcsFolderName);
|
|
34
|
+
|
|
35
|
+
// Strict Repository Location Isolation Assertions:
|
|
36
|
+
// 1. Storage MUST be inside vcsPath (.vcsgib_init_test)
|
|
37
|
+
const ibgibInsideVcsFolder = existsSync(path.join(res.vcsPath, 'ibgib')) || existsSync(path.join(res.vcsPath, 'space'));
|
|
38
|
+
iReckon(lc, ibgibInsideVcsFolder).isGonnaBeTrue();
|
|
39
|
+
|
|
40
|
+
// 2. Storage MUST NOT spill into testDir root or process.cwd() as stray 'ibgib' folder
|
|
41
|
+
const strayInTestDir = existsSync(path.join(testDir, 'ibgib'));
|
|
42
|
+
const strayInCwd = existsSync(path.join(process.cwd(), 'ibgib'));
|
|
43
|
+
iReckon(lc, strayInTestDir).isGonnaBeFalse();
|
|
44
|
+
iReckon(lc, strayInCwd).isGonnaBeFalse();
|
|
45
|
+
} finally {
|
|
46
|
+
await fs.rm(testDir, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module log-cmd
|
|
3
|
+
*
|
|
4
|
+
* Command handler for `vcs log`.
|
|
5
|
+
* Reads active branch timeline from B2tFSIndexIbGib_V1 in localSpace,
|
|
6
|
+
* walks branch timeline history backward, and displays formatted commit history.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import fs from 'node:fs/promises';
|
|
11
|
+
|
|
12
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
|
+
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
14
|
+
import { getIbGibsFromCache_fallbackToSpaces } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
15
|
+
import { CommentIbGib_V1 } from '@ibgib/core-gib/dist/common/comment/comment-types.mjs';
|
|
16
|
+
|
|
17
|
+
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
18
|
+
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
19
|
+
import { getIbGibWithMetaspaceFallback } from '../../engine/item/item-helper.mjs';
|
|
20
|
+
import { B2tFSBranchIbGib_V1 } from '../../engine/branch/branch-types.mjs';
|
|
21
|
+
import { getB2tFSIndexIbGib, extractBranchNameFromAddr } from '../../engine/index/index-helper.mjs';
|
|
22
|
+
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
23
|
+
|
|
24
|
+
const lcFile = `[log-cmd]`;
|
|
25
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
26
|
+
|
|
27
|
+
export interface VcsLogItem {
|
|
28
|
+
branchAddr: string;
|
|
29
|
+
commitAddr: string;
|
|
30
|
+
commentAddr?: string;
|
|
31
|
+
message: string;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
author: string;
|
|
34
|
+
rootItemAddr?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface LogCmdOpts {
|
|
38
|
+
targetDir?: string;
|
|
39
|
+
vcsFolderName?: string;
|
|
40
|
+
quiet?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LogCmdResult {
|
|
44
|
+
branchName: string;
|
|
45
|
+
commits: VcsLogItem[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function executeLogCmd({
|
|
49
|
+
targetDir = process.cwd(),
|
|
50
|
+
vcsFolderName = '.vcsgib',
|
|
51
|
+
quiet = false,
|
|
52
|
+
}: LogCmdOpts = {}): Promise<LogCmdResult> {
|
|
53
|
+
const lc = `${lcFile}[${executeLogCmd.name}]`;
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (logalot) {
|
|
57
|
+
console.log(`${lc} starting executeLogCmd (I: 1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e)`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const absTargetDir = path.resolve(targetDir);
|
|
61
|
+
|
|
62
|
+
const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
|
|
63
|
+
repoPath: absTargetDir,
|
|
64
|
+
vcsFolderName,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Verify repo exists
|
|
68
|
+
try {
|
|
69
|
+
await fs.access(vcsPath);
|
|
70
|
+
} catch {
|
|
71
|
+
throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f)`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 1. Fetch authoritative B2tFSIndexIbGib_V1 directly from localSpace
|
|
75
|
+
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, vcsPath });
|
|
76
|
+
if (!indexIbGib) {
|
|
77
|
+
throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a)`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const branchName = indexIbGib.data?.activeBranch || 'main';
|
|
81
|
+
|
|
82
|
+
// Target active branch space b2s_<activeBranch>
|
|
83
|
+
const { space: activeSpace } = await getOrCreateBranchSpace({
|
|
84
|
+
metaspace,
|
|
85
|
+
vcsPath,
|
|
86
|
+
branchName,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// 2. Fetch active branch node address matching active branchName
|
|
90
|
+
const branchAddrs = [
|
|
91
|
+
...(indexIbGib.rel8ns?.branch || []),
|
|
92
|
+
...(indexIbGib.rel8ns?.branch_tjp || []),
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
let currBranchAddr: string | undefined;
|
|
96
|
+
|
|
97
|
+
// Match branchName against branchAddrs by space-qualified address or raw atom ib string
|
|
98
|
+
for (const addr of branchAddrs) {
|
|
99
|
+
const parsedName = extractBranchNameFromAddr(addr);
|
|
100
|
+
if (parsedName === branchName) {
|
|
101
|
+
currBranchAddr = addr;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Fallback: fetch branch nodes via getIbGibWithMetaspaceFallback to match b.data?.name === branchName
|
|
107
|
+
if (!currBranchAddr) {
|
|
108
|
+
for (const addr of branchAddrs) {
|
|
109
|
+
const bIbGib = await getIbGibWithMetaspaceFallback({
|
|
110
|
+
addr,
|
|
111
|
+
space: activeSpace,
|
|
112
|
+
metaspace,
|
|
113
|
+
}) as B2tFSBranchIbGib_V1;
|
|
114
|
+
if (bIbGib?.data?.name === branchName) {
|
|
115
|
+
currBranchAddr = addr;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Ultimate fallback if no match found
|
|
122
|
+
if (!currBranchAddr) {
|
|
123
|
+
currBranchAddr = branchAddrs.at(0);
|
|
124
|
+
}
|
|
125
|
+
const visitedAddrs = new Set<string>();
|
|
126
|
+
const commits: VcsLogItem[] = [];
|
|
127
|
+
|
|
128
|
+
// 3. Walk timeline history backward
|
|
129
|
+
while (currBranchAddr && !visitedAddrs.has(currBranchAddr)) {
|
|
130
|
+
visitedAddrs.add(currBranchAddr);
|
|
131
|
+
|
|
132
|
+
const branchIbGib = await getIbGibWithMetaspaceFallback({
|
|
133
|
+
addr: currBranchAddr,
|
|
134
|
+
space: activeSpace,
|
|
135
|
+
metaspace,
|
|
136
|
+
}) as B2tFSBranchIbGib_V1;
|
|
137
|
+
|
|
138
|
+
if (!branchIbGib) {
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const commentAddr = branchIbGib.rel8ns?.comment?.at(0);
|
|
143
|
+
const rootItemAddr = branchIbGib.rel8ns?.b2tfs_item?.at(0);
|
|
144
|
+
|
|
145
|
+
if (commentAddr) {
|
|
146
|
+
const commentIbGib = await getIbGibWithMetaspaceFallback({
|
|
147
|
+
addr: commentAddr,
|
|
148
|
+
space: activeSpace,
|
|
149
|
+
metaspace,
|
|
150
|
+
}) as CommentIbGib_V1;
|
|
151
|
+
|
|
152
|
+
const message = commentIbGib?.data?.text || '';
|
|
153
|
+
const timestamp = commentIbGib?.data?.textTimestamp || commentIbGib?.data?.timestamp || branchIbGib.data?.committedAt || '';
|
|
154
|
+
const author = 'vcs-user';
|
|
155
|
+
|
|
156
|
+
commits.push({
|
|
157
|
+
branchAddr: currBranchAddr,
|
|
158
|
+
commitAddr: commentAddr,
|
|
159
|
+
commentAddr,
|
|
160
|
+
message,
|
|
161
|
+
timestamp,
|
|
162
|
+
author,
|
|
163
|
+
rootItemAddr,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Move to previous branch node in timeline
|
|
168
|
+
currBranchAddr = branchIbGib.rel8ns?.past?.at(0) || branchIbGib.rel8ns?.ancestor?.at(0);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!quiet) {
|
|
172
|
+
console.log(`Branch: ${branchName} (I: 4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b)`);
|
|
173
|
+
if (commits.length === 0) {
|
|
174
|
+
console.log('No commits yet.');
|
|
175
|
+
} else {
|
|
176
|
+
for (const commit of commits) {
|
|
177
|
+
console.log(`\ncommit ${commit.commitAddr}`);
|
|
178
|
+
console.log(`Author: ${commit.author}`);
|
|
179
|
+
console.log(`Date: ${commit.timestamp}`);
|
|
180
|
+
console.log(`\n ${commit.message}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
branchName,
|
|
187
|
+
commits,
|
|
188
|
+
};
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: 5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c)`);
|
|
191
|
+
throw error;
|
|
192
|
+
} finally {
|
|
193
|
+
if (logalot) {
|
|
194
|
+
console.log(`${lc} complete. (I: 6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d)`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|