@ibgib/vcs-gib 0.0.32 → 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.
Files changed (132) hide show
  1. package/dist/AUTO-GENERATED-version.d.mts +1 -1
  2. package/dist/AUTO-GENERATED-version.mjs +1 -1
  3. package/dist/bootstrap/node-bootstrap.d.mts.map +1 -1
  4. package/dist/bootstrap/node-bootstrap.mjs +6 -20
  5. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  6. package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +1 -1
  7. package/dist/cli/commands/cli-add-cmd.d.mts.map +1 -0
  8. package/dist/cli/commands/cli-add-cmd.mjs +45 -0
  9. package/dist/cli/commands/cli-add-cmd.mjs.map +1 -0
  10. package/dist/cli/commands/{branch-cmd.d.mts → cli-branch-cmd.d.mts} +1 -1
  11. package/dist/cli/commands/cli-branch-cmd.d.mts.map +1 -0
  12. package/dist/cli/commands/cli-branch-cmd.mjs +59 -0
  13. package/dist/cli/commands/cli-branch-cmd.mjs.map +1 -0
  14. package/dist/cli/commands/{checkout-cmd.d.mts → cli-checkout-cmd.d.mts} +4 -3
  15. package/dist/cli/commands/cli-checkout-cmd.d.mts.map +1 -0
  16. package/dist/cli/commands/cli-checkout-cmd.mjs +50 -0
  17. package/dist/cli/commands/cli-checkout-cmd.mjs.map +1 -0
  18. package/dist/cli/commands/{commit-cmd.d.mts → cli-commit-cmd.d.mts} +1 -1
  19. package/dist/cli/commands/cli-commit-cmd.d.mts.map +1 -0
  20. package/dist/cli/commands/cli-commit-cmd.mjs +52 -0
  21. package/dist/cli/commands/cli-commit-cmd.mjs.map +1 -0
  22. package/dist/cli/commands/{generate-comment-cmd.d.mts → cli-generate-comment-cmd.d.mts} +1 -1
  23. package/dist/cli/commands/cli-generate-comment-cmd.d.mts.map +1 -0
  24. package/dist/cli/commands/{generate-comment-cmd.mjs → cli-generate-comment-cmd.mjs} +8 -6
  25. package/dist/cli/commands/cli-generate-comment-cmd.mjs.map +1 -0
  26. package/dist/cli/commands/{init-cmd.d.mts → cli-init-cmd.d.mts} +1 -1
  27. package/dist/cli/commands/cli-init-cmd.d.mts.map +1 -0
  28. package/dist/cli/commands/cli-init-cmd.mjs +47 -0
  29. package/dist/cli/commands/cli-init-cmd.mjs.map +1 -0
  30. package/dist/cli/commands/{log-cmd.d.mts → cli-log-cmd.d.mts} +1 -1
  31. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
  32. package/dist/cli/commands/{log-cmd.mjs → cli-log-cmd.mjs} +14 -44
  33. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
  34. package/dist/cli/commands/{merge-cmd.d.mts → cli-merge-cmd.d.mts} +1 -1
  35. package/dist/cli/commands/cli-merge-cmd.d.mts.map +1 -0
  36. package/dist/cli/commands/cli-merge-cmd.mjs +66 -0
  37. package/dist/cli/commands/cli-merge-cmd.mjs.map +1 -0
  38. package/dist/cli/commands/{reset-cmd.d.mts → cli-reset-cmd.d.mts} +1 -1
  39. package/dist/cli/commands/cli-reset-cmd.d.mts.map +1 -0
  40. package/dist/cli/commands/cli-reset-cmd.mjs +63 -0
  41. package/dist/cli/commands/cli-reset-cmd.mjs.map +1 -0
  42. package/dist/cli/commands/{restore-cmd.d.mts → cli-restore-cmd.d.mts} +1 -1
  43. package/dist/cli/commands/cli-restore-cmd.d.mts.map +1 -0
  44. package/dist/cli/commands/cli-restore-cmd.mjs +55 -0
  45. package/dist/cli/commands/cli-restore-cmd.mjs.map +1 -0
  46. package/dist/cli/commands/{status-cmd.d.mts → cli-status-cmd.d.mts} +1 -1
  47. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
  48. package/dist/cli/commands/{status-cmd.mjs → cli-status-cmd.mjs} +4 -41
  49. package/dist/cli/commands/cli-status-cmd.mjs.map +1 -0
  50. package/dist/cli/vcs-cli-main.d.mts.map +1 -1
  51. package/dist/cli/vcs-cli-main.mjs +18 -15
  52. package/dist/cli/vcs-cli-main.mjs.map +1 -1
  53. package/dist/cli/vcs-projection-helper.mjs +7 -7
  54. package/dist/cli/vcs-projection-helper.mjs.map +1 -1
  55. package/dist/cli/vcs-repo-helper.d.mts +19 -0
  56. package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
  57. package/dist/cli/vcs-repo-helper.mjs +74 -0
  58. package/dist/cli/vcs-repo-helper.mjs.map +1 -0
  59. package/dist/test/test-helpers.d.mts +9 -0
  60. package/dist/test/test-helpers.d.mts.map +1 -1
  61. package/dist/test/test-helpers.mjs +35 -0
  62. package/dist/test/test-helpers.mjs.map +1 -1
  63. package/package.json +6 -6
  64. package/src/AUTO-GENERATED-version.mts +1 -1
  65. package/src/bootstrap/node-bootstrap.mts +6 -20
  66. package/src/bootstrap/node-bootstrap.respec.mts +2 -2
  67. package/src/cli/cli-arg-parser.respec.mts +2 -2
  68. package/src/cli/cli-e2e.respec.mts +8 -8
  69. package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
  70. package/src/cli/commands/cli-add-cmd.mts +65 -0
  71. package/src/cli/commands/cli-branch-cmd.mts +87 -0
  72. package/src/cli/commands/cli-checkout-cmd.mts +72 -0
  73. package/src/cli/commands/cli-commit-cmd.mts +77 -0
  74. package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +8 -6
  75. package/src/cli/commands/cli-init-cmd.mts +78 -0
  76. package/src/cli/commands/{log-cmd.mts → cli-log-cmd.mts} +14 -47
  77. package/src/cli/commands/cli-merge-cmd.mts +99 -0
  78. package/src/cli/commands/cli-reset-cmd.mts +94 -0
  79. package/src/cli/commands/cli-restore-cmd.mts +87 -0
  80. package/src/cli/commands/{status-cmd.mts → cli-status-cmd.mts} +3 -45
  81. package/src/cli/commands/commit-log-cmd.respec.mts +82 -29
  82. package/src/cli/commands/init-cmd.respec.mts +3 -3
  83. package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
  84. package/src/cli/commands/status-add-cmd.respec.mts +20 -16
  85. package/src/cli/vcs-cli-main.mts +18 -15
  86. package/src/cli/vcs-projection-helper.mts +8 -8
  87. package/src/cli/vcs-repo-helper.mts +99 -0
  88. package/src/engine/branch/branch-space.respec.mts +22 -20
  89. package/src/engine/merge/b2tfs-sync-comments.respec.mts +10 -10
  90. package/src/test/test-helpers.mts +49 -1
  91. package/src/vcs-gib.respec.mts +21 -15
  92. package/tsconfig.test.tsbuildinfo +1 -1
  93. package/tsconfig.tsbuildinfo +1 -1
  94. package/vcs-gib_test_output.md +58 -0
  95. package/dist/cli/commands/add-cmd.d.mts.map +0 -1
  96. package/dist/cli/commands/add-cmd.mjs +0 -93
  97. package/dist/cli/commands/add-cmd.mjs.map +0 -1
  98. package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
  99. package/dist/cli/commands/branch-cmd.mjs +0 -107
  100. package/dist/cli/commands/branch-cmd.mjs.map +0 -1
  101. package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
  102. package/dist/cli/commands/checkout-cmd.mjs +0 -95
  103. package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
  104. package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
  105. package/dist/cli/commands/commit-cmd.mjs +0 -99
  106. package/dist/cli/commands/commit-cmd.mjs.map +0 -1
  107. package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
  108. package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
  109. package/dist/cli/commands/init-cmd.d.mts.map +0 -1
  110. package/dist/cli/commands/init-cmd.mjs +0 -69
  111. package/dist/cli/commands/init-cmd.mjs.map +0 -1
  112. package/dist/cli/commands/log-cmd.d.mts.map +0 -1
  113. package/dist/cli/commands/log-cmd.mjs.map +0 -1
  114. package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
  115. package/dist/cli/commands/merge-cmd.mjs +0 -106
  116. package/dist/cli/commands/merge-cmd.mjs.map +0 -1
  117. package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
  118. package/dist/cli/commands/reset-cmd.mjs +0 -91
  119. package/dist/cli/commands/reset-cmd.mjs.map +0 -1
  120. package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
  121. package/dist/cli/commands/restore-cmd.mjs +0 -97
  122. package/dist/cli/commands/restore-cmd.mjs.map +0 -1
  123. package/dist/cli/commands/status-cmd.d.mts.map +0 -1
  124. package/dist/cli/commands/status-cmd.mjs.map +0 -1
  125. package/src/cli/commands/add-cmd.mts +0 -120
  126. package/src/cli/commands/branch-cmd.mts +0 -142
  127. package/src/cli/commands/checkout-cmd.mts +0 -123
  128. package/src/cli/commands/commit-cmd.mts +0 -130
  129. package/src/cli/commands/init-cmd.mts +0 -99
  130. package/src/cli/commands/merge-cmd.mts +0 -143
  131. package/src/cli/commands/reset-cmd.mts +0 -126
  132. package/src/cli/commands/restore-cmd.mts +0 -135
@@ -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
+ }
@@ -6,17 +6,10 @@
6
6
  */
7
7
 
8
8
  import path from 'node:path';
9
- import fs from 'node:fs/promises';
10
9
 
11
10
  import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
12
- import { executeVcsStatus } from '@ibgib/core-gib/dist/vcs/commands/status-cmd.mjs';
13
11
  import { VcsStatusItem, PendingCommentInfo } from '@ibgib/core-gib/dist/vcs/status/status-helper.mjs';
14
- import { resolveContextualBranchName } from '@ibgib/core-gib/dist/vcs/branch/branch-helper.mjs';
15
-
16
- import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
17
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
18
- import { getOrCreateWorkspaceProjectionSpace } from '@ibgib/node-gib/dist/vcs/workspace-space-helper.mjs';
19
- import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
12
+ import { openVcsRepository } from '../vcs-repo-helper.mjs';
20
13
  import { GLOBAL_LOG_A_LOT } from '../../vcs-gib-constants.mjs';
21
14
 
22
15
  const lcFile = `[status-cmd]`;
@@ -54,45 +47,10 @@ export async function executeStatusCmd({
54
47
  }
55
48
 
56
49
  const absTargetDir = path.resolve(targetDir);
50
+ const { repo } = await openVcsRepository({ targetDir: absTargetDir, vcsFolderName });
57
51
 
58
- const { metaspace, localSpace, vcsPath, repoRoot } = await bootstrapVcsMetaspace({
59
- repoPath: absTargetDir,
60
- vcsFolderName,
61
- });
62
-
63
- // Verify repo exists
64
- try {
65
- await fs.access(vcsPath);
66
- } catch {
67
- throw new Error(`Not an ibgib repository (directory ${vcsPath} does not exist) (E: 4d5e6f7a8b9c10d11e12f13a14b15c6d)`);
68
- }
69
-
70
- const indexIbGib = await readVcsIndexProjectionFromDisk({ vcsPath, space: localSpace });
71
- const branchName = resolveContextualBranchName({ targetDir: absTargetDir, repoRoot, indexIbGib });
72
- const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
73
-
74
- const { space: activeBranchSpace } = await getOrCreateBranchSpace({
75
- metaspace,
76
- vcsPath,
77
- branchName,
78
- });
79
-
80
- const { space: workspaceSpace } = await getOrCreateWorkspaceProjectionSpace({
81
- metaspace,
82
- workspaceRoot: activeWorktreeDir,
83
- vcsFolderName,
84
- backingSpace: activeBranchSpace,
85
- });
86
-
87
- const statusRes = await executeVcsStatus({
88
- metaspace,
89
- localSpace,
90
- activeBranchSpace,
91
- workspaceSpace,
92
- indexIbGib,
93
- repoRoot,
52
+ const statusRes = await repo.status({
94
53
  targetDir: absTargetDir,
95
- vcsFolderName,
96
54
  });
97
55
 
98
56
  const { staged, modified, deleted, untracked, pendingComments } = statusRes;
@@ -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 { getFromSpace } from '@ibgib/core-gib/dist/witness/space/space-helper.mjs';
16
- import { executeInitCmd } from './init-cmd.mjs';
17
- import { executeAddCmd } from './add-cmd.mjs';
18
- import { executeStatusCmd } from './status-cmd.mjs';
19
- import { executeCommitCmd } from './commit-cmd.mjs';
20
- import { executeLogCmd } from './log-cmd.mjs';
21
- import { executeBranchCmd } from './branch-cmd.mjs';
22
- import { executeCheckoutCmd } from './checkout-cmd.mjs';
23
- import { executeMergeCmd } from './merge-cmd.mjs';
24
- import { executeGenerateCommentCmd } from './generate-comment-cmd.mjs';
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
33
  import { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
27
- import { getOrCreateBranchSpace } from '@ibgib/node-gib/dist/vcs/branch-space-helper.mjs';
28
- import { getIbGibWithMetaspaceFallback } from '@ibgib/core-gib/dist/vcs/item/item-helper.mjs';
29
34
 
30
- const lc = `[apps/vcs-gib/src/cli/commands/commit-log-cmd.respec.node.mts]`;
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
 
@@ -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({ incomingBranchName: 'feature-comments', targetDir: testDir, vcsFolderName, quiet: true });
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,33 +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 readVcsIndexProjectionFromDisk({ space: metaspace.zeroSpace, vcsPath });
462
- const branchAddrs = [
463
- ...(indexIbGib?.rel8ns?.branch || []),
464
- ...(indexIbGib?.rel8ns?.branch_tjp || []),
465
- ];
466
- const mainBranchAddr = branchAddrs.find(a => a.includes('main')) || branchAddrs.at(-1);
467
- const mainBranch = await getIbGibWithMetaspaceFallback({ addr: mainBranchAddr!, space: mainSpace, metaspace });
468
- const mainRootAddr = mainBranch?.rel8ns?.b2tfs_item?.at(-1);
469
- const mainRoot = await getIbGibWithMetaspaceFallback({ addr: mainRootAddr!, space: mainSpace, metaspace });
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
+
470
517
  let appItem: any;
471
- for (const childAddr of mainRoot?.rel8ns?.b2tfs_child || []) {
472
- const child = await getIbGibWithMetaspaceFallback({ addr: childAddr, space: mainSpace, metaspace });
473
- if (child?.data?.name === 'app.ts') {
474
- appItem = child;
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;
475
524
  break;
476
525
  }
477
526
  }
@@ -486,6 +535,10 @@ await respecfully(lc, `vcs commit and vcs log Command Handlers`, async () => {
486
535
  const graphValues = Object.values(depGraph);
487
536
  const foundCommentB = graphValues.some(x => (x.data as any)?.text === 'feat(feature-comments): updated b to 200');
488
537
  iReckon(lc, foundCommentB).isGonnaBeTruthy();
538
+ } catch (error) {
539
+ const emsg = extractErrorMsg(error);
540
+ console.error(emsg);
541
+ iReckon(lc, true).asTo(emsg).isGonnaBeFalse();
489
542
  } finally {
490
543
  await fs.rm(testDir, { recursive: true, force: true });
491
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.node.mts]`;
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.node.mts]`;
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
 
@@ -11,18 +11,20 @@ import {
11
11
  respecfully, ifWe, ifWeMight, iReckon
12
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
13
13
 
14
- import { executeInitCmd } from './init-cmd.mjs';
15
- import { executeStatusCmd } from './status-cmd.mjs';
16
- import { executeAddCmd } from './add-cmd.mjs';
17
- import { executeCommitCmd } from './commit-cmd.mjs';
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 { readVcsIndexProjectionFromDisk } from '../vcs-projection-helper.mjs';
20
22
 
21
- const lc = `[apps/vcs-gib/src/cli/commands/status-add-cmd.respec.node.mts]`;
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 ifWe(lc, `detects untracked files in fresh repository`, async () => {
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 ifWe(lc, `discovers .vcsgib via upward discovery when executed from a subfolder`, async () => {
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 ifWe(lc, `skips re-staging unmodified committed files during executeAddCmd with all flag`, async () => {
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 ifWe(lc, `stages untracked file via executeAddCmd`, async () => {
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 { localSpace, vcsPath } = await bootstrapVcsMetaspace({
143
+ const { metaspace, localSpace } = await bootstrapVcsMetaspace({
142
144
  repoPath: testDir,
143
145
  vcsFolderName,
144
146
  });
145
- const indexIbGib = await readVcsIndexProjectionFromDisk({ space: localSpace, vcsPath });
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 ifWe(lc, `respects .ibgibignore patterns during status and add`, async () => {
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 ifWe(lc, `stages files matching glob pattern with executeAddCmd`, async () => {
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 ifWe(lc, `stages relative file paths correctly when targetDir is a subdirectory`, async () => {
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
  }
@@ -10,17 +10,17 @@ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs
10
10
 
11
11
  import { parseVcsArgs } from './cli-arg-parser.mjs';
12
12
  import { VCS_SUBCOMMANDS } from './cli-constants.mjs';
13
- import { executeInitCmd } from './commands/init-cmd.mjs';
14
- import { executeStatusCmd } from './commands/status-cmd.mjs';
15
- import { executeAddCmd } from './commands/add-cmd.mjs';
16
- import { executeCommitCmd } from './commands/commit-cmd.mjs';
17
- import { executeLogCmd } from './commands/log-cmd.mjs';
18
- import { executeBranchCmd } from './commands/branch-cmd.mjs';
19
- import { executeCheckoutCmd } from './commands/checkout-cmd.mjs';
20
- import { executeMergeCmd } from './commands/merge-cmd.mjs';
21
- import { executeResetCmd } from './commands/reset-cmd.mjs';
22
- import { executeRestoreCmd } from './commands/restore-cmd.mjs';
23
- import { executeGenerateCommentCmd } from './commands/generate-comment-cmd.mjs';
13
+ import { executeInitCmd } from './commands/cli-init-cmd.mjs';
14
+ import { executeStatusCmd } from './commands/cli-status-cmd.mjs';
15
+ import { executeAddCmd } from './commands/cli-add-cmd.mjs';
16
+ import { executeCommitCmd } from './commands/cli-commit-cmd.mjs';
17
+ import { executeLogCmd } from './commands/cli-log-cmd.mjs';
18
+ import { executeBranchCmd } from './commands/cli-branch-cmd.mjs';
19
+ import { executeCheckoutCmd } from './commands/cli-checkout-cmd.mjs';
20
+ import { executeMergeCmd } from './commands/cli-merge-cmd.mjs';
21
+ import { executeResetCmd } from './commands/cli-reset-cmd.mjs';
22
+ import { executeRestoreCmd } from './commands/cli-restore-cmd.mjs';
23
+ import { executeGenerateCommentCmd } from './commands/cli-generate-comment-cmd.mjs';
24
24
  import { AUTO_GENERATED_VERSION } from '../AUTO-GENERATED-version.mjs';
25
25
  import { GLOBAL_LOG_A_LOT } from '../vcs-gib-constants.mjs';
26
26
 
@@ -76,7 +76,7 @@ export async function main({
76
76
  const lc = `${lcFile}[${main.name}]`;
77
77
  try {
78
78
  if (logalot) {
79
- console.log(`${lc} starting... (I: 4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e)`);
79
+ console.log(`${lc} starting... (I: genuuid)`);
80
80
  }
81
81
 
82
82
  const parsed = parseVcsArgs(argv);
@@ -140,7 +140,10 @@ export async function main({
140
140
  }
141
141
  case VCS_SUBCOMMANDS.CHECKOUT: {
142
142
  const branchName = parsed.positionals[0] || parsed.flags.branchName;
143
- await executeCheckoutCmd({ branchName });
143
+ await executeCheckoutCmd({
144
+ branchName,
145
+ force: parsed.flags.force,
146
+ });
144
147
  break;
145
148
  }
146
149
  case VCS_SUBCOMMANDS.MERGE: {
@@ -180,11 +183,11 @@ export async function main({
180
183
 
181
184
  return 0;
182
185
  } catch (error) {
183
- console.error(`Error: ${extractErrorMsg(error)} (E: 8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d)`);
186
+ console.error(`Error: ${extractErrorMsg(error)} (E: genuuid)`);
184
187
  return 1;
185
188
  } finally {
186
189
  if (logalot) {
187
- console.log(`${lc} complete. (I: 9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c)`);
190
+ console.log(`${lc} complete. (I: genuuid)`);
188
191
  }
189
192
  }
190
193
  }