@ibgib/vcs-gib 0.0.30 → 0.0.33
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.d.mts.map +1 -1
- package/dist/bootstrap/node-bootstrap.mjs +7 -21
- package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
- package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +3 -4
- package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-add-cmd.mjs +45 -0
- package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
- package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +9 -9
- package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
- package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-checkout-cmd.d.mts +20 -0
- package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
- package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-commit-cmd.d.mts +23 -0
- package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
- package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
- package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
- package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +11 -6
- package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
- package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +3 -3
- package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-init-cmd.mjs +47 -0
- package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
- package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +3 -4
- package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-log-cmd.mjs +90 -0
- package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-merge-cmd.d.mts +22 -0
- package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
- package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
- package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +2 -2
- package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
- package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
- package/dist/cli/commands/cli-restore-cmd.d.mts +23 -0
- package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
- package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
- package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +3 -3
- package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
- package/dist/cli/commands/cli-status-cmd.mjs +96 -0
- package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
- package/dist/cli/vcs-cli-main.d.mts.map +1 -1
- package/dist/cli/vcs-cli-main.mjs +18 -15
- package/dist/cli/vcs-cli-main.mjs.map +1 -1
- package/dist/cli/vcs-projection-helper.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/cli/vcs-repo-helper.d.mts +19 -0
- package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
- package/dist/cli/vcs-repo-helper.mjs +74 -0
- package/dist/cli/vcs-repo-helper.mjs.map +1 -0
- package/dist/test/test-helpers.d.mts +11 -2
- package/dist/test/test-helpers.d.mts.map +1 -1
- package/dist/test/test-helpers.mjs +35 -0
- package/dist/test/test-helpers.mjs.map +1 -1
- package/package.json +6 -6
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/bootstrap/node-bootstrap.mts +7 -21
- package/src/bootstrap/node-bootstrap.respec.mts +2 -2
- package/src/cli/cli-arg-parser.respec.mts +2 -2
- package/src/cli/cli-e2e.respec.mts +12 -12
- package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
- package/src/cli/commands/cli-add-cmd.mts +65 -0
- package/src/cli/commands/cli-branch-cmd.mts +87 -0
- package/src/cli/commands/cli-checkout-cmd.mts +72 -0
- package/src/cli/commands/cli-commit-cmd.mts +77 -0
- package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +12 -6
- package/src/cli/commands/cli-init-cmd.mts +78 -0
- package/src/cli/commands/cli-log-cmd.mts +126 -0
- package/src/cli/commands/cli-merge-cmd.mts +99 -0
- package/src/cli/commands/cli-reset-cmd.mts +94 -0
- package/src/cli/commands/cli-restore-cmd.mts +87 -0
- package/src/cli/commands/cli-status-cmd.mts +131 -0
- package/src/cli/commands/commit-log-cmd.respec.mts +85 -28
- package/src/cli/commands/init-cmd.respec.mts +3 -3
- package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
- package/src/cli/commands/status-add-cmd.respec.mts +21 -17
- package/src/cli/vcs-cli-main.mts +18 -15
- package/src/cli/vcs-projection-helper.mts +112 -0
- package/src/cli/vcs-repo-helper.mts +99 -0
- package/src/engine/branch/branch-space.respec.mts +23 -21
- package/src/engine/merge/b2tfs-sync-comments.respec.mts +11 -11
- package/src/test/test-helpers.mts +50 -2
- package/src/vcs-gib.respec.mts +25 -16
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vcs-gib_test_output.md +58 -0
- package/dist/cli/commands/add-cmd.d.mts.map +0 -1
- package/dist/cli/commands/add-cmd.mjs +0 -346
- package/dist/cli/commands/add-cmd.mjs.map +0 -1
- package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
- package/dist/cli/commands/branch-cmd.mjs +0 -238
- package/dist/cli/commands/branch-cmd.mjs.map +0 -1
- package/dist/cli/commands/checkout-cmd.d.mts +0 -21
- package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
- package/dist/cli/commands/checkout-cmd.mjs +0 -174
- package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
- package/dist/cli/commands/commit-cmd.d.mts +0 -24
- package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
- package/dist/cli/commands/commit-cmd.mjs +0 -449
- package/dist/cli/commands/commit-cmd.mjs.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
- package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
- package/dist/cli/commands/init-cmd.d.mts.map +0 -1
- package/dist/cli/commands/init-cmd.mjs +0 -119
- package/dist/cli/commands/init-cmd.mjs.map +0 -1
- package/dist/cli/commands/log-cmd.d.mts.map +0 -1
- package/dist/cli/commands/log-cmd.mjs +0 -349
- package/dist/cli/commands/log-cmd.mjs.map +0 -1
- package/dist/cli/commands/merge-cmd.d.mts +0 -36
- package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
- package/dist/cli/commands/merge-cmd.mjs +0 -292
- package/dist/cli/commands/merge-cmd.mjs.map +0 -1
- package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
- package/dist/cli/commands/reset-cmd.mjs +0 -93
- package/dist/cli/commands/reset-cmd.mjs.map +0 -1
- package/dist/cli/commands/restore-cmd.d.mts +0 -22
- package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
- package/dist/cli/commands/restore-cmd.mjs +0 -115
- package/dist/cli/commands/restore-cmd.mjs.map +0 -1
- package/dist/cli/commands/status-cmd.d.mts.map +0 -1
- package/dist/cli/commands/status-cmd.mjs +0 -132
- package/dist/cli/commands/status-cmd.mjs.map +0 -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/cli/commands/add-cmd.mts +0 -435
- package/src/cli/commands/branch-cmd.mts +0 -311
- package/src/cli/commands/checkout-cmd.mts +0 -227
- package/src/cli/commands/commit-cmd.mts +0 -557
- package/src/cli/commands/init-cmd.mts +0 -152
- package/src/cli/commands/log-cmd.mts +0 -449
- package/src/cli/commands/merge-cmd.mts +0 -363
- package/src/cli/commands/reset-cmd.mts +0 -128
- package/src/cli/commands/restore-cmd.mts +0 -155
- package/src/cli/commands/status-cmd.mts +0 -168
- 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
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module reset-cmd
|
|
3
|
+
*
|
|
4
|
+
* CLI command handler for `vcs reset [path...]`.
|
|
5
|
+
* Unstages specified files (or all files) from active branch index in localSpace.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
|
+
|
|
11
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { promptForConfirm } from '@ibgib/helper-gib/dist/helpers/node-helper.mjs';
|
|
13
|
+
import { openVcsRepository } from '../vcs-repo-helper.mjs';
|
|
14
|
+
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
15
|
+
|
|
16
|
+
const lcFile = `[reset-cmd]`;
|
|
17
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
18
|
+
|
|
19
|
+
export interface ResetCmdOpts {
|
|
20
|
+
paths?: string[];
|
|
21
|
+
targetDir?: string;
|
|
22
|
+
vcsFolderName?: string;
|
|
23
|
+
all?: boolean;
|
|
24
|
+
yes?: boolean;
|
|
25
|
+
force?: boolean;
|
|
26
|
+
quiet?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ResetCmdResult {
|
|
30
|
+
unstagedPaths: string[];
|
|
31
|
+
stagedCount: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function executeResetCmd({
|
|
35
|
+
paths = [],
|
|
36
|
+
targetDir = process.cwd(),
|
|
37
|
+
vcsFolderName = '.vcsgib',
|
|
38
|
+
all = false,
|
|
39
|
+
yes = false,
|
|
40
|
+
force = false,
|
|
41
|
+
quiet = false,
|
|
42
|
+
}: ResetCmdOpts = {}): Promise<ResetCmdResult> {
|
|
43
|
+
const lc = `${lcFile}[${executeResetCmd.name}]`;
|
|
44
|
+
try {
|
|
45
|
+
if (logalot) {
|
|
46
|
+
console.log(`${lc} starting... (I: genuuid)`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const absTargetDir = path.resolve(targetDir);
|
|
50
|
+
const { repo, activeWorktreeDir } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
|
|
51
|
+
|
|
52
|
+
const indexIbGib = await repo.getIndexIbGib();
|
|
53
|
+
const activeBranchSpace = await repo.getActiveBranchSpace(indexIbGib);
|
|
54
|
+
|
|
55
|
+
const skipPrompt = yes || force || quiet || !process.stdin.isTTY;
|
|
56
|
+
if (!skipPrompt) {
|
|
57
|
+
const confirmed = await promptForConfirm({ msg: 'Unstage specified files from index?' });
|
|
58
|
+
if (!confirmed) {
|
|
59
|
+
if (!quiet) {
|
|
60
|
+
console.log('Operation cancelled.');
|
|
61
|
+
}
|
|
62
|
+
const stagedCount = Object.keys(indexIbGib.data.stagedPaths || {}).length;
|
|
63
|
+
return { unstagedPaths: [], stagedCount };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const resetRes = await repo.reset({
|
|
68
|
+
activeBranchSpace,
|
|
69
|
+
indexIbGib,
|
|
70
|
+
paths,
|
|
71
|
+
all,
|
|
72
|
+
targetDir: absTargetDir,
|
|
73
|
+
activeWorktreeDir,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (!quiet) {
|
|
77
|
+
for (const unstagedPath of resetRes.unstagedPaths) {
|
|
78
|
+
console.log(`unstaged: ${unstagedPath}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
unstagedPaths: resetRes.unstagedPaths,
|
|
84
|
+
stagedCount: resetRes.stagedCount,
|
|
85
|
+
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
|
|
88
|
+
throw error;
|
|
89
|
+
} finally {
|
|
90
|
+
if (logalot) {
|
|
91
|
+
console.log(`${lc} complete. (I: genuuid)`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module restore-cmd
|
|
3
|
+
*
|
|
4
|
+
* CLI command handler for `vcs restore [path...]`.
|
|
5
|
+
* Delegates to executeVcsRestore and formats terminal output.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
|
+
|
|
11
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
12
|
+
import { openVcsRepository } from '../vcs-repo-helper.mjs';
|
|
13
|
+
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
14
|
+
|
|
15
|
+
const lcFile = `[restore-cmd]`;
|
|
16
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
17
|
+
|
|
18
|
+
export interface RestoreCmdOpts {
|
|
19
|
+
paths?: string[];
|
|
20
|
+
staged?: boolean;
|
|
21
|
+
worktree?: boolean;
|
|
22
|
+
all?: boolean;
|
|
23
|
+
yes?: boolean;
|
|
24
|
+
force?: boolean;
|
|
25
|
+
targetDir?: string;
|
|
26
|
+
vcsFolderName?: string;
|
|
27
|
+
quiet?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RestoreCmdResult {
|
|
31
|
+
restoredPaths: string[];
|
|
32
|
+
unstagedPaths: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function executeRestoreCmd({
|
|
36
|
+
paths = [],
|
|
37
|
+
staged = false,
|
|
38
|
+
worktree = false,
|
|
39
|
+
all = false,
|
|
40
|
+
yes = false,
|
|
41
|
+
force = false,
|
|
42
|
+
targetDir = process.cwd(),
|
|
43
|
+
vcsFolderName = '.vcsgib',
|
|
44
|
+
quiet = false,
|
|
45
|
+
}: RestoreCmdOpts = {}): Promise<RestoreCmdResult> {
|
|
46
|
+
const lc = `${lcFile}[${executeRestoreCmd.name}]`;
|
|
47
|
+
try {
|
|
48
|
+
if (logalot) {
|
|
49
|
+
console.log(`${lc} starting... (I: genuuid)`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const absTargetDir = path.resolve(targetDir);
|
|
53
|
+
const { repo, activeWorktreeDir } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
|
|
54
|
+
|
|
55
|
+
const restoreRes = await repo.restore({
|
|
56
|
+
paths,
|
|
57
|
+
staged,
|
|
58
|
+
all,
|
|
59
|
+
targetDir: absTargetDir,
|
|
60
|
+
activeWorktreeDir,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (!quiet) {
|
|
64
|
+
if (staged) {
|
|
65
|
+
for (const unstagedPath of restoreRes.unstagedPaths) {
|
|
66
|
+
console.log(`unstaged: ${unstagedPath}`);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
for (const restoredPath of restoreRes.restoredPaths) {
|
|
70
|
+
console.log(`restored: ${restoredPath}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
restoredPaths: restoreRes.restoredPaths,
|
|
77
|
+
unstagedPaths: restoreRes.unstagedPaths,
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: genuuid)`);
|
|
81
|
+
throw error;
|
|
82
|
+
} finally {
|
|
83
|
+
if (logalot) {
|
|
84
|
+
console.log(`${lc} complete. (I: genuuid)`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module status-cmd
|
|
3
|
+
*
|
|
4
|
+
* CLI command handler for `vcs status`.
|
|
5
|
+
* Compares physical workspace state against active branch snapshot tip and in-band index staging area.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
11
|
+
import { VcsStatusItem, PendingCommentInfo } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
|
|
12
|
+
import { openVcsRepository } from '../vcs-repo-helper.mjs';
|
|
13
|
+
import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
|
|
14
|
+
|
|
15
|
+
const lcFile = `[status-cmd]`;
|
|
16
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
17
|
+
|
|
18
|
+
export { VcsStatusItem, PendingCommentInfo };
|
|
19
|
+
|
|
20
|
+
export interface StatusCmdResult {
|
|
21
|
+
branchName: string;
|
|
22
|
+
staged: VcsStatusItem[];
|
|
23
|
+
modified: VcsStatusItem[];
|
|
24
|
+
deleted: VcsStatusItem[];
|
|
25
|
+
untracked: VcsStatusItem[];
|
|
26
|
+
pendingComments: PendingCommentInfo[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface StatusCmdOpts {
|
|
30
|
+
targetDir?: string;
|
|
31
|
+
vcsFolderName?: string;
|
|
32
|
+
quiet?: boolean;
|
|
33
|
+
comments?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function executeStatusCmd({
|
|
37
|
+
targetDir = process.cwd(),
|
|
38
|
+
vcsFolderName = '.vcsgib',
|
|
39
|
+
quiet = false,
|
|
40
|
+
comments = false,
|
|
41
|
+
}: StatusCmdOpts = {}): Promise<StatusCmdResult> {
|
|
42
|
+
const lc = `${lcFile}[${executeStatusCmd.name}]`;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (logalot) {
|
|
46
|
+
console.log(`${lc} starting executeStatusCmd (I: 7a8b9c10d11e12f13a14b15c16d17e18)`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const absTargetDir = path.resolve(targetDir);
|
|
50
|
+
const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
|
|
51
|
+
|
|
52
|
+
const statusRes = await repo.status({
|
|
53
|
+
targetDir: absTargetDir,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const { staged, modified, deleted, untracked, pendingComments } = statusRes;
|
|
57
|
+
|
|
58
|
+
const commentsByTarget = new Map<string, PendingCommentInfo[]>();
|
|
59
|
+
for (const c of pendingComments) {
|
|
60
|
+
const list = commentsByTarget.get(c.targetRelPath) || [];
|
|
61
|
+
list.push(c);
|
|
62
|
+
commentsByTarget.set(c.targetRelPath, list);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!quiet) {
|
|
66
|
+
console.log(`On branch ${statusRes.branchName} (I: 5e6f7a8b9c10d11e12f13a14b15c16d1)`);
|
|
67
|
+
|
|
68
|
+
if (staged.length === 0 && modified.length === 0 && deleted.length === 0 && untracked.length === 0 && pendingComments.length === 0) {
|
|
69
|
+
console.log('nothing to commit, working tree clean');
|
|
70
|
+
} else {
|
|
71
|
+
if (staged.length > 0) {
|
|
72
|
+
console.log('\nChanges to be committed:');
|
|
73
|
+
console.log(' (use "vcs reset <file>..." to unstage)');
|
|
74
|
+
for (const item of staged) {
|
|
75
|
+
const typePrefix = item.fsType === 'folder' ? 'directory: ' : '';
|
|
76
|
+
console.log(`\tnew file: ${typePrefix}${item.path}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (modified.length > 0 || deleted.length > 0) {
|
|
81
|
+
console.log('\nChanges not staged for commit:');
|
|
82
|
+
console.log(' (use "vcs add <file>..." to update what will be committed)');
|
|
83
|
+
console.log(' (use "vcs restore <file>..." to discard changes in working directory)');
|
|
84
|
+
for (const item of modified) {
|
|
85
|
+
console.log(`\tmodified: ${item.path}`);
|
|
86
|
+
}
|
|
87
|
+
for (const item of deleted) {
|
|
88
|
+
console.log(`\tdeleted: ${item.path}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (untracked.length > 0) {
|
|
93
|
+
console.log('\nUntracked files:');
|
|
94
|
+
console.log(' (use "vcs add <file>..." to include in what will be committed)');
|
|
95
|
+
for (const item of untracked) {
|
|
96
|
+
const suffix = item.fsType === 'folder' ? '/' : '';
|
|
97
|
+
console.log(`\t${item.path}${suffix}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (pendingComments.length > 0) {
|
|
102
|
+
console.log('\nPending companion comments:');
|
|
103
|
+
console.log(' (will be attached to items upon "vcs commit")');
|
|
104
|
+
for (const comment of pendingComments) {
|
|
105
|
+
const targetLabel = comment.targetRelPath ? comment.targetRelPath : '(root)';
|
|
106
|
+
console.log(`\tcomment on [${targetLabel}]: ${comment.commentRelPath}`);
|
|
107
|
+
if (comments) {
|
|
108
|
+
console.log(`\t Preview: ${comment.content.slice(0, 80).replace(/\n/g, ' ')}...`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
branchName: statusRes.branchName,
|
|
117
|
+
staged,
|
|
118
|
+
modified,
|
|
119
|
+
deleted,
|
|
120
|
+
untracked,
|
|
121
|
+
pendingComments,
|
|
122
|
+
};
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(`${lc} ${extractErrorMsg(error)} (E: 6f7a8b9c10d11e12f13a14b15c16d17e)`);
|
|
125
|
+
throw error;
|
|
126
|
+
} finally {
|
|
127
|
+
if (logalot) {
|
|
128
|
+
console.log(`${lc} complete. (I: 8a9b10c11d12e13f14a15b16c17d18e1)`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -11,23 +11,28 @@ import {
|
|
|
11
11
|
respecfully, ifWe, ifWeMight, iReckon
|
|
12
12
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
13
13
|
|
|
14
|
+
import { extractErrorMsg, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
14
15
|
import { getDependencyGraph } from '@ibgib/core-gib/dist/common/other/graph-helper.mjs';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
16
|
+
import { getLatestAddrs } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
|
|
17
|
+
import { getB2tFSIndexIbGib, } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
18
|
+
import { getOrCreateBranchSpace, parseBranchIb } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
|
|
19
|
+
import { B2tFSBranchIbGib_V1 } from '@ibgib/core-gib/dist/vcs/branch/branch-types.mjs';
|
|
20
|
+
import { B2tFSItemIbGib_V1 } from '@ibgib/core-gib/dist/vcs/item/item-types.mjs';
|
|
21
|
+
import { getIbGibFromSpace, parseSpaceQualifiedIbGibAddr } from '@ibgib/core-gib/dist/common/other/ibgib-helper.mjs';
|
|
22
|
+
|
|
23
|
+
import { executeInitCmd } from './cli-init-cmd.mjs';
|
|
24
|
+
import { executeAddCmd } from './cli-add-cmd.mjs';
|
|
25
|
+
import { executeStatusCmd } from './cli-status-cmd.mjs';
|
|
26
|
+
import { executeCommitCmd } from './cli-commit-cmd.mjs';
|
|
27
|
+
import { executeLogCmd } from './cli-log-cmd.mjs';
|
|
28
|
+
import { executeBranchCmd } from './cli-branch-cmd.mjs';
|
|
29
|
+
import { executeCheckoutCmd } from './cli-checkout-cmd.mjs';
|
|
30
|
+
import { executeMergeCmd } from './cli-merge-cmd.mjs';
|
|
31
|
+
import { executeGenerateCommentCmd } from './cli-generate-comment-cmd.mjs';
|
|
25
32
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
26
|
-
import {
|
|
27
|
-
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
28
|
-
import { getIbGibWithMetaspaceFallback } from '../../engine/item/item-helper.mjs';
|
|
33
|
+
import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
|
|
29
34
|
|
|
30
|
-
const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.
|
|
35
|
+
const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.mts]`;
|
|
31
36
|
|
|
32
37
|
await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
33
38
|
|
|
@@ -119,7 +124,7 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
119
124
|
repoPath: testDir,
|
|
120
125
|
vcsFolderName,
|
|
121
126
|
});
|
|
122
|
-
const indexAdd = await
|
|
127
|
+
const indexAdd = await readVcsIndexProjectionFromDisk({ space: spaceAdd, vcsPath: vcsPathAdd });
|
|
123
128
|
iReckon(lc, Boolean(indexAdd?.data?.staged_item && indexAdd.data.staged_item.length > 0)).isGonnaBeTrue();
|
|
124
129
|
iReckon(lc, indexAdd?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
125
130
|
|
|
@@ -134,7 +139,7 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
134
139
|
repoPath: testDir,
|
|
135
140
|
vcsFolderName,
|
|
136
141
|
});
|
|
137
|
-
const indexCommit = await
|
|
142
|
+
const indexCommit = await readVcsIndexProjectionFromDisk({ space: spaceCommit, vcsPath: vcsPathCommit });
|
|
138
143
|
iReckon(lc, indexCommit?.data?.staged_item).willEqual([]);
|
|
139
144
|
iReckon(lc, indexCommit?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
140
145
|
|
|
@@ -149,9 +154,11 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
149
154
|
quiet: true,
|
|
150
155
|
});
|
|
151
156
|
|
|
157
|
+
console.log(`[TEST-LOG] statusRes: staged=${statusRes.staged.length}, modified=${statusRes.modified.length}, untracked=${statusRes.untracked.length}`);
|
|
152
158
|
iReckon(lc, statusRes.staged.length).willEqual(0);
|
|
153
159
|
iReckon(lc, statusRes.modified.length).willEqual(0);
|
|
154
160
|
iReckon(lc, statusRes.untracked.length).willEqual(0);
|
|
161
|
+
console.log(`[TEST-LOG] statusRes assertions complete.`);
|
|
155
162
|
} finally {
|
|
156
163
|
await fs.rm(testDir, { recursive: true, force: true });
|
|
157
164
|
}
|
|
@@ -434,7 +441,9 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
434
441
|
await executeCommitCmd({ message: 'Main branch update', targetDir: testDir, vcsFolderName, quiet: true });
|
|
435
442
|
|
|
436
443
|
// Merge feature-comments into main
|
|
437
|
-
await executeMergeCmd({
|
|
444
|
+
await executeMergeCmd({
|
|
445
|
+
incomingBranchName: 'feature-comments', targetDir: testDir, vcsFolderName, quiet: true
|
|
446
|
+
});
|
|
438
447
|
|
|
439
448
|
// Check file log on main: both comments should be present!
|
|
440
449
|
const mergedFileLog = await executeLogCmd({
|
|
@@ -445,29 +454,73 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
445
454
|
});
|
|
446
455
|
|
|
447
456
|
const allMessages = mergedFileLog.commits.map(c => c.message).join(' -- ');
|
|
457
|
+
console.log(`allMessages: ${pretty(allMessages)}`);
|
|
458
|
+
iReckon(lc, allMessages).includes(`\n\n${pretty(allMessages)}\n\n`);
|
|
448
459
|
iReckon(lc, allMessages).includes('updated b to 200');
|
|
449
460
|
iReckon(lc, allMessages).includes('updated a to 100');
|
|
450
461
|
|
|
451
462
|
// Verify getDependencyGraph works 100% within main branch space alone (no metaspace fallback)
|
|
452
|
-
const { metaspace, vcsPath } = await bootstrapVcsMetaspace({
|
|
463
|
+
const { metaspace, localSpace, vcsPath } = await bootstrapVcsMetaspace({
|
|
453
464
|
repoPath: testDir,
|
|
454
465
|
vcsFolderName,
|
|
455
466
|
});
|
|
456
467
|
const { space: mainSpace } = await getOrCreateBranchSpace({
|
|
457
468
|
metaspace,
|
|
458
|
-
vcsPath,
|
|
459
469
|
branchName: 'main',
|
|
460
470
|
});
|
|
461
|
-
const indexIbGib = await getB2tFSIndexIbGib({ space:
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
471
|
+
const indexIbGib = (await getB2tFSIndexIbGib({ space: localSpace, metaspace }))
|
|
472
|
+
|| (await readVcsIndexProjectionFromDisk({ space: localSpace, vcsPath }));
|
|
473
|
+
if (!indexIbGib) { throw new Error(`(UNEXPECTED) indexIbGib falsy? (E: d4ec1b6f86cbf18808fba957b7b83826)`); }
|
|
474
|
+
const branchAddrs_spacequalified = indexIbGib.data['$@branch'] ?? [];
|
|
475
|
+
if (branchAddrs_spacequalified.length === 0) {
|
|
476
|
+
throw new Error(`(UNEXPECTED) indexIbGib doesn't have any branch addrs in data? (E: 7069280124b81c6d1806fc580c704826)`);
|
|
477
|
+
}
|
|
478
|
+
const branchAddrs_spacequalified_main = branchAddrs_spacequalified
|
|
479
|
+
.filter(x => {
|
|
480
|
+
const parsedBranchAddrInfo = parseSpaceQualifiedIbGibAddr({ sqAddr: x });
|
|
481
|
+
if (!parsedBranchAddrInfo) { throw new Error(`(UNEXPECTED) parsedBranchAddrInfo falsy? space-qualified branch addr couldn't be parsed? (E: 779b886c5a6d64b0ce0e8c185952b526)`); }
|
|
482
|
+
const parsedBranchIb = parseBranchIb({ ib: parsedBranchAddrInfo.ib });
|
|
483
|
+
return parsedBranchIb.branchName === 'main';
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
if (branchAddrs_spacequalified_main.length !== 1) { throw new Error(`(UNEXPECTED) branchAddrs_spacequalified_main.length !== 1? (E: 3ec21f70cca8b2347de407abc9062826)`); }
|
|
487
|
+
|
|
488
|
+
const mainBranchAddr_spaceQualified = branchAddrs_spacequalified_main[0];
|
|
489
|
+
|
|
490
|
+
const mainBranchAddrInfo = parseSpaceQualifiedIbGibAddr({
|
|
491
|
+
sqAddr: mainBranchAddr_spaceQualified
|
|
492
|
+
});
|
|
493
|
+
if (!mainBranchAddrInfo) { throw new Error(`(UNEXPECTED) mainBranchAddrInfo falsy? couldn't parse it? (E: ae570ae49e190727fc4464183ab87226)`); }
|
|
494
|
+
|
|
495
|
+
const resLatestMainBranchAddrs = await getLatestAddrs({
|
|
496
|
+
addrs: [mainBranchAddrInfo.ibGibAddr],
|
|
497
|
+
space: mainSpace,
|
|
498
|
+
});
|
|
499
|
+
if (!resLatestMainBranchAddrs) { throw new Error(`resLatestMainBranchAddrs falsy (E: f22b6325ec6804046899e49d8076d826)`); }
|
|
500
|
+
if (!resLatestMainBranchAddrs.data) { throw new Error(`(UNEXPECTED) resLatestMainBranchAddrs.data falsy? (E: 2709383cb8943aeb0801bf2541f91826)`); }
|
|
501
|
+
if (!resLatestMainBranchAddrs.data.latestAddrsMap) { throw new Error(`resLatestMainBranchAddrs.data.latestAddrsMap falsy (E: 4b3824e20968409128270faf093a6826)`); }
|
|
502
|
+
if (Object.keys(resLatestMainBranchAddrs.data.latestAddrsMap).length !== 1) { throw new Error(`(UNEXPECTED) resLatestMainBranchAddrs.data.latestAddrsMap not size 1? (E: bffbbd29f0222027d824e1b810281826)`); }
|
|
503
|
+
|
|
504
|
+
let latestMainAddr =
|
|
505
|
+
Object.values(resLatestMainBranchAddrs.data.latestAddrsMap).at(0) || mainBranchAddrInfo.ibGibAddr;
|
|
506
|
+
const latestMainBranchIbGib = await getIbGibFromSpace<B2tFSBranchIbGib_V1>({ addr: latestMainAddr, space: mainSpace });
|
|
507
|
+
if (!latestMainBranchIbGib) { throw new Error(`(UNEXPECTED) latestMainBranchIbGib? (E: 29b2884d60eac1fb98d512f81af8f826)`); }
|
|
508
|
+
|
|
509
|
+
if (!latestMainBranchIbGib.rel8ns) { throw new Error(`(UNEXPECTED) latestMainBranchIbGib.rel8ns falsy? (E: 3c70081bde0d9cce68b857b829472726)`); }
|
|
510
|
+
if (!latestMainBranchIbGib.rel8ns.b2tfs_item) { throw new Error(`latestMainBranchIbGib.rel8ns.b2tfs_item falsy (E: 6ab0d8c90628c10e020b22b862590f26)`); }
|
|
511
|
+
const mainRootItemAddr = latestMainBranchIbGib.rel8ns.b2tfs_item.at(-1);
|
|
512
|
+
if (!mainRootItemAddr) { throw new Error(`(UNEXPECTED) mainRootItemAddr falsy? we always should have a root item related to the branch ibgib. (E: 7897abafda988af1333d3048aa7a9826)`); }
|
|
513
|
+
const mainRootItem = await getIbGibFromSpace<B2tFSItemIbGib_V1>({ addr: mainRootItemAddr, space: mainSpace, });
|
|
514
|
+
if (!mainRootItem) { throw new Error(`(UNEXPECTED) mainRootItem falsy? (E: 4e5afe38b7fb1f560494b61a82bdd526)`); }
|
|
515
|
+
if (!mainRootItem.rel8ns) { throw new Error(`(UNEXPECTED) mainRootItem.rel8ns falsy? (E: 0301644482a6431419243c528f121826)`); }
|
|
516
|
+
|
|
466
517
|
let appItem: any;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
518
|
+
// Bill: is mainRootItem definitely a folder in this test? someone should double-check this.
|
|
519
|
+
for (const childAddr of mainRootItem?.rel8ns?.b2tfs_child || []) {
|
|
520
|
+
const childOfMainRootItem = await getIbGibFromSpace<B2tFSItemIbGib_V1>({ addr: childAddr, space: mainSpace, metaspace });
|
|
521
|
+
if (!childOfMainRootItem) { throw new Error(`(UNEXPECTED) childOfMainRootItem falsy? (E: 216428e870884ba2e8c854c25f914826)`); }
|
|
522
|
+
if (childOfMainRootItem.data.name === 'app.ts') {
|
|
523
|
+
appItem = childOfMainRootItem;
|
|
471
524
|
break;
|
|
472
525
|
}
|
|
473
526
|
}
|
|
@@ -482,6 +535,10 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
|
|
|
482
535
|
const graphValues = Object.values(depGraph);
|
|
483
536
|
const foundCommentB = graphValues.some(x => (x.data as any)?.text === 'feat(feature-comments): updated b to 200');
|
|
484
537
|
iReckon(lc, foundCommentB).isGonnaBeTruthy();
|
|
538
|
+
} catch (error) {
|
|
539
|
+
const emsg = extractErrorMsg(error);
|
|
540
|
+
console.error(emsg);
|
|
541
|
+
iReckon(lc, true).asTo(emsg).isGonnaBeFalse();
|
|
485
542
|
} finally {
|
|
486
543
|
await fs.rm(testDir, { recursive: true, force: true });
|
|
487
544
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module init-cmd.respec
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Unit tests for `vcs init` command handler.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
respecfully, ifWe, iReckon
|
|
13
13
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
14
14
|
|
|
15
|
-
import { executeInitCmd } from './init-cmd.mjs';
|
|
15
|
+
import { executeInitCmd } from './cli-init-cmd.mjs';
|
|
16
16
|
|
|
17
|
-
const lc = `[apps/vcs-gib/src/cli/commands/init-cmd.respec.
|
|
17
|
+
const lc = `[apps/vcs-gib/src/cli/commands/init-cmd.respec.mts]`;
|
|
18
18
|
|
|
19
19
|
await respecfully(lc, `vcs init Command Handler`, async () => {
|
|
20
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module reset-restore-cmd.respec
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Unit tests for `vcs reset` and `vcs restore` command handlers.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -8,17 +8,17 @@ import path from 'node:path';
|
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
respecfully, ifWe, iReckon
|
|
11
|
+
respecfully, ifWe, iReckon, ifWeMight, // don't remove unused ifWe or ifWeMight
|
|
12
12
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
13
13
|
|
|
14
|
-
import { executeInitCmd } from './init-cmd.mjs';
|
|
15
|
-
import { executeAddCmd } from './add-cmd.mjs';
|
|
16
|
-
import { executeCommitCmd } from './commit-cmd.mjs';
|
|
17
|
-
import { executeStatusCmd } from './status-cmd.mjs';
|
|
18
|
-
import { executeResetCmd } from './reset-cmd.mjs';
|
|
19
|
-
import { executeRestoreCmd } from './restore-cmd.mjs';
|
|
14
|
+
import { executeInitCmd } from './cli-init-cmd.mjs';
|
|
15
|
+
import { executeAddCmd } from './cli-add-cmd.mjs';
|
|
16
|
+
import { executeCommitCmd } from './cli-commit-cmd.mjs';
|
|
17
|
+
import { executeStatusCmd } from './cli-status-cmd.mjs';
|
|
18
|
+
import { executeResetCmd } from './cli-reset-cmd.mjs';
|
|
19
|
+
import { executeRestoreCmd } from './cli-restore-cmd.mjs';
|
|
20
20
|
|
|
21
|
-
const lc = `[apps/vcs-gib/src/cli/commands/reset-restore-cmd.respec.
|
|
21
|
+
const lc = `[apps/vcs-gib/src/cli/commands/reset-restore-cmd.respec.mts]`;
|
|
22
22
|
|
|
23
23
|
await respecfully(lc, `vcs reset and vcs restore Command Handlers`, async () => {
|
|
24
24
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module status-add-cmd.respec
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Unit tests for `vcs status` and `vcs add` command handlers.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -8,21 +8,23 @@ import path from 'node:path';
|
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
respecfully, ifWe, iReckon
|
|
11
|
+
respecfully, ifWe, ifWeMight, iReckon
|
|
12
12
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import {
|
|
14
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
15
|
+
import { getB2tFSIndexIbGib } from '@ibgib/core-gib/dist/vcs/index/index-helper.mjs';
|
|
16
|
+
|
|
17
|
+
import { executeInitCmd } from './cli-init-cmd.mjs';
|
|
18
|
+
import { executeStatusCmd } from './cli-status-cmd.mjs';
|
|
19
|
+
import { executeAddCmd } from './cli-add-cmd.mjs';
|
|
20
|
+
import { executeCommitCmd } from './cli-commit-cmd.mjs';
|
|
18
21
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
19
|
-
import { getB2tFSIndexIbGib } from '../../engine/index/index-helper.mjs';
|
|
20
22
|
|
|
21
|
-
const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.
|
|
23
|
+
const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.mts]`;
|
|
22
24
|
|
|
23
25
|
await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
24
26
|
|
|
25
|
-
await
|
|
27
|
+
await ifWeMight(lc, `detects untracked files in fresh repository`, async () => {
|
|
26
28
|
const testDir = path.join(process.cwd(), '.test_status_add_1');
|
|
27
29
|
const vcsFolderName = '.vcsgib_test_1';
|
|
28
30
|
try {
|
|
@@ -48,7 +50,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
await
|
|
53
|
+
await ifWeMight(lc, `discovers .vcsgib via upward discovery when executed from a subfolder`, async () => {
|
|
52
54
|
const testDir = path.join(process.cwd(), '.test_status_add_subfolder');
|
|
53
55
|
const vcsFolderName = '.vcsgib_test_subfolder';
|
|
54
56
|
try {
|
|
@@ -75,7 +77,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
75
77
|
}
|
|
76
78
|
});
|
|
77
79
|
|
|
78
|
-
await
|
|
80
|
+
await ifWeMight(lc, `skips re-staging unmodified committed files during executeAddCmd with all flag`, async () => {
|
|
79
81
|
const testDir = path.join(process.cwd(), '.test_status_add_unmodified');
|
|
80
82
|
const vcsFolderName = '.vcsgib_test_unmodified';
|
|
81
83
|
try {
|
|
@@ -116,7 +118,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
116
118
|
}
|
|
117
119
|
});
|
|
118
120
|
|
|
119
|
-
await
|
|
121
|
+
await ifWeMight(lc, `stages untracked file via executeAddCmd`, async () => {
|
|
120
122
|
const testDir = path.join(process.cwd(), '.test_status_add_2');
|
|
121
123
|
const vcsFolderName = '.vcsgib_test_2';
|
|
122
124
|
try {
|
|
@@ -138,11 +140,11 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
138
140
|
|
|
139
141
|
iReckon(lc, addRes.stagedPaths).includes('file1.txt');
|
|
140
142
|
|
|
141
|
-
const {
|
|
143
|
+
const { metaspace, localSpace } = await bootstrapVcsMetaspace({
|
|
142
144
|
repoPath: testDir,
|
|
143
145
|
vcsFolderName,
|
|
144
146
|
});
|
|
145
|
-
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace,
|
|
147
|
+
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, metaspace });
|
|
146
148
|
iReckon(lc, Boolean(indexIbGib?.data?.staged_item && indexIbGib.data.staged_item.length > 0)).isGonnaBeTrue();
|
|
147
149
|
iReckon(lc, indexIbGib?.rel8ns?.staged_item).isGonnaBeFalsy();
|
|
148
150
|
|
|
@@ -160,7 +162,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
160
162
|
}
|
|
161
163
|
});
|
|
162
164
|
|
|
163
|
-
await
|
|
165
|
+
await ifWeMight(lc, `respects .ibgibignore patterns during status and add`, async () => {
|
|
164
166
|
const testDir = path.join(process.cwd(), '.test_status_add_3');
|
|
165
167
|
const vcsFolderName = '.vcsgib_test_3';
|
|
166
168
|
try {
|
|
@@ -201,7 +203,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
201
203
|
}
|
|
202
204
|
});
|
|
203
205
|
|
|
204
|
-
await
|
|
206
|
+
await ifWeMight(lc, `stages files matching glob pattern with executeAddCmd`, async () => {
|
|
205
207
|
const testDir = path.join(process.cwd(), '.test_status_add_glob');
|
|
206
208
|
const vcsFolderName = '.vcsgib_test_glob';
|
|
207
209
|
try {
|
|
@@ -244,7 +246,7 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
244
246
|
}
|
|
245
247
|
});
|
|
246
248
|
|
|
247
|
-
await
|
|
249
|
+
await ifWeMight(lc, `stages relative file paths correctly when targetDir is a subdirectory`, async () => {
|
|
248
250
|
const testDir = path.join(process.cwd(), '.test_status_add_subdir');
|
|
249
251
|
const vcsFolderName = '.vcsgib_test_subdir';
|
|
250
252
|
try {
|
|
@@ -266,6 +268,8 @@ await respecfully(lc, `vcs status and vcs add Command Handlers`, async () => {
|
|
|
266
268
|
});
|
|
267
269
|
|
|
268
270
|
iReckon(lc, addRes.stagedPaths).includes('src/utils/math.js');
|
|
271
|
+
} catch (error) {
|
|
272
|
+
iReckon(lc, true).asTo(extractErrorMsg(error)).isGonnaBeFalse();
|
|
269
273
|
} finally {
|
|
270
274
|
await fs.rm(testDir, { recursive: true, force: true });
|
|
271
275
|
}
|