@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.
Files changed (216) 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 +7 -21
  5. package/dist/bootstrap/node-bootstrap.mjs.map +1 -1
  6. package/dist/cli/commands/{add-cmd.d.mts → cli-add-cmd.d.mts} +3 -4
  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} +9 -9
  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/cli-checkout-cmd.d.mts +20 -0
  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/cli-commit-cmd.d.mts +23 -0
  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} +11 -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} +3 -3
  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} +3 -4
  31. package/dist/cli/commands/cli-log-cmd.d.mts.map +1 -0
  32. package/dist/cli/commands/cli-log-cmd.mjs +90 -0
  33. package/dist/cli/commands/cli-log-cmd.mjs.map +1 -0
  34. package/dist/cli/commands/cli-merge-cmd.d.mts +22 -0
  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} +2 -2
  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/cli-restore-cmd.d.mts +23 -0
  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} +3 -3
  47. package/dist/cli/commands/cli-status-cmd.d.mts.map +1 -0
  48. package/dist/cli/commands/cli-status-cmd.mjs +96 -0
  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.d.mts +23 -0
  54. package/dist/cli/vcs-projection-helper.d.mts.map +1 -0
  55. package/dist/cli/vcs-projection-helper.mjs +91 -0
  56. package/dist/cli/vcs-projection-helper.mjs.map +1 -0
  57. package/dist/cli/vcs-repo-helper.d.mts +19 -0
  58. package/dist/cli/vcs-repo-helper.d.mts.map +1 -0
  59. package/dist/cli/vcs-repo-helper.mjs +74 -0
  60. package/dist/cli/vcs-repo-helper.mjs.map +1 -0
  61. package/dist/test/test-helpers.d.mts +11 -2
  62. package/dist/test/test-helpers.d.mts.map +1 -1
  63. package/dist/test/test-helpers.mjs +35 -0
  64. package/dist/test/test-helpers.mjs.map +1 -1
  65. package/package.json +6 -6
  66. package/src/AUTO-GENERATED-version.mts +1 -1
  67. package/src/bootstrap/node-bootstrap.mts +7 -21
  68. package/src/bootstrap/node-bootstrap.respec.mts +2 -2
  69. package/src/cli/cli-arg-parser.respec.mts +2 -2
  70. package/src/cli/cli-e2e.respec.mts +12 -12
  71. package/src/cli/commands/branch-checkout-cmd.respec.mts +426 -412
  72. package/src/cli/commands/cli-add-cmd.mts +65 -0
  73. package/src/cli/commands/cli-branch-cmd.mts +87 -0
  74. package/src/cli/commands/cli-checkout-cmd.mts +72 -0
  75. package/src/cli/commands/cli-commit-cmd.mts +77 -0
  76. package/src/cli/commands/{generate-comment-cmd.mts → cli-generate-comment-cmd.mts} +12 -6
  77. package/src/cli/commands/cli-init-cmd.mts +78 -0
  78. package/src/cli/commands/cli-log-cmd.mts +126 -0
  79. package/src/cli/commands/cli-merge-cmd.mts +99 -0
  80. package/src/cli/commands/cli-reset-cmd.mts +94 -0
  81. package/src/cli/commands/cli-restore-cmd.mts +87 -0
  82. package/src/cli/commands/cli-status-cmd.mts +131 -0
  83. package/src/cli/commands/commit-log-cmd.respec.mts +85 -28
  84. package/src/cli/commands/init-cmd.respec.mts +3 -3
  85. package/src/cli/commands/reset-restore-cmd.respec.mts +9 -9
  86. package/src/cli/commands/status-add-cmd.respec.mts +21 -17
  87. package/src/cli/vcs-cli-main.mts +18 -15
  88. package/src/cli/vcs-projection-helper.mts +112 -0
  89. package/src/cli/vcs-repo-helper.mts +99 -0
  90. package/src/engine/branch/branch-space.respec.mts +23 -21
  91. package/src/engine/merge/b2tfs-sync-comments.respec.mts +11 -11
  92. package/src/test/test-helpers.mts +50 -2
  93. package/src/vcs-gib.respec.mts +25 -16
  94. package/tsconfig.test.tsbuildinfo +1 -1
  95. package/tsconfig.tsbuildinfo +1 -1
  96. package/vcs-gib_test_output.md +58 -0
  97. package/dist/cli/commands/add-cmd.d.mts.map +0 -1
  98. package/dist/cli/commands/add-cmd.mjs +0 -346
  99. package/dist/cli/commands/add-cmd.mjs.map +0 -1
  100. package/dist/cli/commands/branch-cmd.d.mts.map +0 -1
  101. package/dist/cli/commands/branch-cmd.mjs +0 -238
  102. package/dist/cli/commands/branch-cmd.mjs.map +0 -1
  103. package/dist/cli/commands/checkout-cmd.d.mts +0 -21
  104. package/dist/cli/commands/checkout-cmd.d.mts.map +0 -1
  105. package/dist/cli/commands/checkout-cmd.mjs +0 -174
  106. package/dist/cli/commands/checkout-cmd.mjs.map +0 -1
  107. package/dist/cli/commands/commit-cmd.d.mts +0 -24
  108. package/dist/cli/commands/commit-cmd.d.mts.map +0 -1
  109. package/dist/cli/commands/commit-cmd.mjs +0 -449
  110. package/dist/cli/commands/commit-cmd.mjs.map +0 -1
  111. package/dist/cli/commands/generate-comment-cmd.d.mts.map +0 -1
  112. package/dist/cli/commands/generate-comment-cmd.mjs.map +0 -1
  113. package/dist/cli/commands/init-cmd.d.mts.map +0 -1
  114. package/dist/cli/commands/init-cmd.mjs +0 -119
  115. package/dist/cli/commands/init-cmd.mjs.map +0 -1
  116. package/dist/cli/commands/log-cmd.d.mts.map +0 -1
  117. package/dist/cli/commands/log-cmd.mjs +0 -349
  118. package/dist/cli/commands/log-cmd.mjs.map +0 -1
  119. package/dist/cli/commands/merge-cmd.d.mts +0 -36
  120. package/dist/cli/commands/merge-cmd.d.mts.map +0 -1
  121. package/dist/cli/commands/merge-cmd.mjs +0 -292
  122. package/dist/cli/commands/merge-cmd.mjs.map +0 -1
  123. package/dist/cli/commands/reset-cmd.d.mts.map +0 -1
  124. package/dist/cli/commands/reset-cmd.mjs +0 -93
  125. package/dist/cli/commands/reset-cmd.mjs.map +0 -1
  126. package/dist/cli/commands/restore-cmd.d.mts +0 -22
  127. package/dist/cli/commands/restore-cmd.d.mts.map +0 -1
  128. package/dist/cli/commands/restore-cmd.mjs +0 -115
  129. package/dist/cli/commands/restore-cmd.mjs.map +0 -1
  130. package/dist/cli/commands/status-cmd.d.mts.map +0 -1
  131. package/dist/cli/commands/status-cmd.mjs +0 -132
  132. package/dist/cli/commands/status-cmd.mjs.map +0 -1
  133. package/dist/engine/branch/branch-graph-helper.d.mts +0 -28
  134. package/dist/engine/branch/branch-graph-helper.d.mts.map +0 -1
  135. package/dist/engine/branch/branch-graph-helper.mjs +0 -81
  136. package/dist/engine/branch/branch-graph-helper.mjs.map +0 -1
  137. package/dist/engine/branch/branch-helper.d.mts +0 -40
  138. package/dist/engine/branch/branch-helper.d.mts.map +0 -1
  139. package/dist/engine/branch/branch-helper.mjs +0 -78
  140. package/dist/engine/branch/branch-helper.mjs.map +0 -1
  141. package/dist/engine/branch/branch-space-helper.d.mts +0 -23
  142. package/dist/engine/branch/branch-space-helper.d.mts.map +0 -1
  143. package/dist/engine/branch/branch-space-helper.mjs +0 -78
  144. package/dist/engine/branch/branch-space-helper.mjs.map +0 -1
  145. package/dist/engine/branch/branch-types.d.mts +0 -26
  146. package/dist/engine/branch/branch-types.d.mts.map +0 -1
  147. package/dist/engine/branch/branch-types.mjs +0 -7
  148. package/dist/engine/branch/branch-types.mjs.map +0 -1
  149. package/dist/engine/diff/line-diff-helper.d.mts +0 -76
  150. package/dist/engine/diff/line-diff-helper.d.mts.map +0 -1
  151. package/dist/engine/diff/line-diff-helper.mjs +0 -144
  152. package/dist/engine/diff/line-diff-helper.mjs.map +0 -1
  153. package/dist/engine/filter/glob-helper.d.mts +0 -51
  154. package/dist/engine/filter/glob-helper.d.mts.map +0 -1
  155. package/dist/engine/filter/glob-helper.mjs +0 -132
  156. package/dist/engine/filter/glob-helper.mjs.map +0 -1
  157. package/dist/engine/index/index-helper.d.mts +0 -113
  158. package/dist/engine/index/index-helper.d.mts.map +0 -1
  159. package/dist/engine/index/index-helper.mjs +0 -533
  160. package/dist/engine/index/index-helper.mjs.map +0 -1
  161. package/dist/engine/index/index-types.d.mts +0 -63
  162. package/dist/engine/index/index-types.d.mts.map +0 -1
  163. package/dist/engine/index/index-types.mjs +0 -7
  164. package/dist/engine/index/index-types.mjs.map +0 -1
  165. package/dist/engine/item/item-atom-helper.d.mts +0 -20
  166. package/dist/engine/item/item-atom-helper.d.mts.map +0 -1
  167. package/dist/engine/item/item-atom-helper.mjs +0 -30
  168. package/dist/engine/item/item-atom-helper.mjs.map +0 -1
  169. package/dist/engine/item/item-helper.d.mts +0 -94
  170. package/dist/engine/item/item-helper.d.mts.map +0 -1
  171. package/dist/engine/item/item-helper.mjs +0 -424
  172. package/dist/engine/item/item-helper.mjs.map +0 -1
  173. package/dist/engine/item/item-types.d.mts +0 -128
  174. package/dist/engine/item/item-types.d.mts.map +0 -1
  175. package/dist/engine/item/item-types.mjs +0 -16
  176. package/dist/engine/item/item-types.mjs.map +0 -1
  177. package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts +0 -74
  178. package/dist/engine/merge/b2tfs-3way-graft-strategy.d.mts.map +0 -1
  179. package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs +0 -570
  180. package/dist/engine/merge/b2tfs-3way-graft-strategy.mjs.map +0 -1
  181. package/dist/engine/merge/b2tfs-3way-graft-types.d.mts +0 -34
  182. package/dist/engine/merge/b2tfs-3way-graft-types.d.mts.map +0 -1
  183. package/dist/engine/merge/b2tfs-3way-graft-types.mjs +0 -2
  184. package/dist/engine/merge/b2tfs-3way-graft-types.mjs.map +0 -1
  185. package/dist/engine/status/status-helper.d.mts +0 -90
  186. package/dist/engine/status/status-helper.d.mts.map +0 -1
  187. package/dist/engine/status/status-helper.mjs +0 -286
  188. package/dist/engine/status/status-helper.mjs.map +0 -1
  189. package/src/cli/commands/add-cmd.mts +0 -435
  190. package/src/cli/commands/branch-cmd.mts +0 -311
  191. package/src/cli/commands/checkout-cmd.mts +0 -227
  192. package/src/cli/commands/commit-cmd.mts +0 -557
  193. package/src/cli/commands/init-cmd.mts +0 -152
  194. package/src/cli/commands/log-cmd.mts +0 -449
  195. package/src/cli/commands/merge-cmd.mts +0 -363
  196. package/src/cli/commands/reset-cmd.mts +0 -128
  197. package/src/cli/commands/restore-cmd.mts +0 -155
  198. package/src/cli/commands/status-cmd.mts +0 -168
  199. package/src/engine/branch/branch-graph-helper.mts +0 -117
  200. package/src/engine/branch/branch-helper.mts +0 -112
  201. package/src/engine/branch/branch-space-helper.mts +0 -110
  202. package/src/engine/branch/branch-types.mts +0 -29
  203. package/src/engine/diff/line-diff-helper.mts +0 -210
  204. package/src/engine/diff/line-diff-helper.respec.mts +0 -84
  205. package/src/engine/filter/glob-helper.mts +0 -165
  206. package/src/engine/filter/glob-helper.respec.mts +0 -94
  207. package/src/engine/index/index-helper.mts +0 -705
  208. package/src/engine/index/index-types.mts +0 -66
  209. package/src/engine/item/item-atom-helper.mts +0 -30
  210. package/src/engine/item/item-helper.mts +0 -544
  211. package/src/engine/item/item-types.mts +0 -137
  212. package/src/engine/item/item.respec.mts +0 -92
  213. package/src/engine/merge/b2tfs-3way-graft-strategy.mts +0 -630
  214. package/src/engine/merge/b2tfs-3way-graft-strategy.respec.mts +0 -346
  215. package/src/engine/merge/b2tfs-3way-graft-types.mts +0 -34
  216. package/src/engine/status/status-helper.mts +0 -383
@@ -8,111 +8,114 @@ import path from 'node:path';
8
8
  import fs from 'node:fs/promises';
9
9
 
10
10
  import {
11
- respecfully, ifWe, iReckon,
12
- ifWeMight
11
+ respecfully, ifWe, iReckon, ifWeMight, // don't remove ifWe/ifWeMight even if unused
13
12
  } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
14
13
 
15
- import { executeInitCmd } from './init-cmd.mjs';
16
- import { executeAddCmd } from './add-cmd.mjs';
17
- import { executeCommitCmd } from './commit-cmd.mjs';
18
- import { executeBranchCmd } from './branch-cmd.mjs';
19
- import { executeCheckoutCmd } from './checkout-cmd.mjs';
20
- import { executeMergeCmd } from './merge-cmd.mjs';
21
- import { executeStatusCmd } from './status-cmd.mjs';
22
- import { executeLogCmd } from './log-cmd.mjs';
14
+ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
15
+
16
+ import { executeInitCmd } from './cli-init-cmd.mjs';
17
+ import { executeAddCmd } from './cli-add-cmd.mjs';
18
+ import { executeCommitCmd } from './cli-commit-cmd.mjs';
19
+ import { executeBranchCmd } from './cli-branch-cmd.mjs';
20
+ import { executeCheckoutCmd } from './cli-checkout-cmd.mjs';
21
+ import { executeMergeCmd } from './cli-merge-cmd.mjs';
22
+ import { executeStatusCmd } from './cli-status-cmd.mjs';
23
+ import { executeLogCmd } from './cli-log-cmd.mjs';
23
24
  import { logCheckpoint } from '../../test/test-helpers.mjs';
24
25
 
25
- const lc = `[apps/vcs-gib/src/cli/commands/branch-checkout-cmd.respec.node.mts]`;
26
+ const lc = `[apps/vcs-gib/src/cli/commands/branch-checkout-cmd.respec.mts]`;
26
27
 
27
28
  await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async () => {
28
29
 
29
- await ifWe(lc, `lists default branch main for new repository`, async () => {
30
- const testDir = path.join(process.cwd(), '.test_branch_checkout_1');
31
- const vcsFolderName = '.vcsgib_test_bc_1';
32
- try {
33
- await executeInitCmd({
34
- targetDir: testDir,
35
- vcsFolderName,
36
- quiet: true,
37
- });
38
-
39
- const branchRes = await executeBranchCmd({
40
- targetDir: testDir,
41
- vcsFolderName,
42
- quiet: true,
43
- });
44
-
45
- iReckon(lc, branchRes.branches.length).willEqual(1);
46
- iReckon(lc, branchRes.branches[0].name).willEqual('main');
47
- iReckon(lc, branchRes.branches[0].isActive).isGonnaBeTrue();
48
- } finally {
49
- await fs.rm(testDir, { recursive: true, force: true });
50
- }
51
- });
52
-
53
- await ifWe(lc, `creates new branch from active branch root item and rejects duplicates`, async () => {
54
- const testDir = path.join(process.cwd(), '.test_branch_checkout_2');
55
- const vcsFolderName = '.vcsgib_test_bc_2';
56
- try {
57
- await executeInitCmd({
58
- targetDir: testDir,
59
- vcsFolderName,
60
- quiet: true,
61
- });
62
-
63
- // Create feature branch
64
- const createRes = await executeBranchCmd({
65
- branchName: 'feature-auth',
66
- targetDir: testDir,
67
- vcsFolderName,
68
- quiet: true,
69
- });
70
-
71
- iReckon(lc, createRes.createdBranchName).willEqual('feature-auth');
72
- iReckon(lc, Boolean(createRes.createdBranchAddr)).isGonnaBeTrue();
73
-
74
- // List branches
75
- const listRes = await executeBranchCmd({
76
- targetDir: testDir,
77
- vcsFolderName,
78
- quiet: true,
79
- });
80
-
81
- iReckon(lc, listRes.branches.length).willEqual(2);
82
- const featureBranch = listRes.branches.find(b => b.name === 'feature-auth');
83
- iReckon(lc, Boolean(featureBranch)).isGonnaBeTrue();
84
- iReckon(lc, featureBranch?.isActive).isGonnaBeFalse();
85
-
86
- // Verify dedicated branch space subfolders exist in .vcsgib
87
- const mainSpaceDir = path.join(testDir, vcsFolderName, 'ibgib', 'b2s_main');
88
- const featureSpaceDir = path.join(testDir, vcsFolderName, 'ibgib', 'b2s_feature-auth');
89
- const mainSpaceExists = await fs.stat(mainSpaceDir).then(s => s.isDirectory()).catch(() =>
90
- fs.stat(path.join(testDir, vcsFolderName, 'b2s_main')).then(s => s.isDirectory()).catch(() => false)
91
- );
92
- const featureSpaceExists = await fs.stat(featureSpaceDir).then(s => s.isDirectory()).catch(() =>
93
- fs.stat(path.join(testDir, vcsFolderName, 'b2s_feature-auth')).then(s => s.isDirectory()).catch(() => false)
94
- );
95
- iReckon(lc, mainSpaceExists).isGonnaBeTrue();
96
- iReckon(lc, featureSpaceExists).isGonnaBeTrue();
97
-
98
- // Duplicate branch attempt
99
- let errorThrown = false;
100
- try {
101
- await executeBranchCmd({
102
- branchName: 'feature-auth',
103
- targetDir: testDir,
104
- vcsFolderName,
105
- quiet: true,
106
- });
107
- } catch (err: any) {
108
- errorThrown = true;
109
- iReckon(lc, err.message).includes("already exists");
110
- }
111
- iReckon(lc, errorThrown).isGonnaBeTrue();
112
- } finally {
113
- await fs.rm(testDir, { recursive: true, force: true });
114
- }
115
- });
30
+ // await ifWe(lc, `lists default branch main for new repository`, async () => {
31
+ // const testDir = path.join(process.cwd(), '.test_branch_checkout_1');
32
+ // const vcsFolderName = '.vcsgib_test_bc_1';
33
+ // try {
34
+ // await executeInitCmd({
35
+ // targetDir: testDir,
36
+ // vcsFolderName,
37
+ // quiet: true,
38
+ // });
39
+
40
+ // const branchRes = await executeBranchCmd({
41
+ // targetDir: testDir,
42
+ // vcsFolderName,
43
+ // quiet: true,
44
+ // });
45
+
46
+ // iReckon(lc, branchRes.branches.length).willEqual(1);
47
+ // iReckon(lc, branchRes.branches[0].name).willEqual('main');
48
+ // iReckon(lc, branchRes.branches[0].isActive).isGonnaBeTrue();
49
+ // } finally {
50
+ // await fs.rm(testDir, { recursive: true, force: true });
51
+ // }
52
+ // });
53
+
54
+ // await ifWe(lc, `creates new branch from active branch root item and rejects duplicates`, async () => {
55
+ // const testDir = path.join(process.cwd(), '.test_branch_checkout_2');
56
+ // const vcsFolderName = '.vcsgib_test_bc_2';
57
+ // try {
58
+ // await executeInitCmd({
59
+ // targetDir: testDir,
60
+ // vcsFolderName,
61
+ // quiet: true,
62
+ // });
63
+
64
+ // // Create feature branch
65
+ // debugger; // walk through branch exec
66
+ // const createRes = await executeBranchCmd({
67
+ // branchName: 'feature-auth',
68
+ // targetDir: testDir,
69
+ // vcsFolderName,
70
+ // quiet: true,
71
+ // });
72
+
73
+ // iReckon(lc, createRes.createdBranchName).willEqual('feature-auth');
74
+ // iReckon(lc, Boolean(createRes.createdBranchAddr)).isGonnaBeTrue();
75
+
76
+ // // List branches
77
+ // const listRes = await executeBranchCmd({
78
+ // targetDir: testDir,
79
+ // vcsFolderName,
80
+ // quiet: true,
81
+ // });
82
+ // console.dir(listRes)
83
+
84
+ // iReckon(lc, listRes.branches.length).willEqual(2);
85
+ // const featureBranch = listRes.branches.find(b => b.name === 'feature-auth');
86
+ // iReckon(lc, Boolean(featureBranch)).isGonnaBeTrue();
87
+ // iReckon(lc, featureBranch?.isActive).isGonnaBeFalse();
88
+
89
+ // // Verify dedicated branch space subfolders exist in .vcsgib
90
+ // const mainSpaceDir = path.join(testDir, vcsFolderName, 'ibgib', 'b2s_main');
91
+ // const featureSpaceDir = path.join(testDir, vcsFolderName, 'ibgib', 'b2s_feature-auth');
92
+ // const mainSpaceExists = await fs.stat(mainSpaceDir).then(s => s.isDirectory()).catch(() =>
93
+ // fs.stat(path.join(testDir, vcsFolderName, 'b2s_main')).then(s => s.isDirectory()).catch(() => false)
94
+ // );
95
+ // const featureSpaceExists = await fs.stat(featureSpaceDir).then(s => s.isDirectory()).catch(() =>
96
+ // fs.stat(path.join(testDir, vcsFolderName, 'b2s_feature-auth')).then(s => s.isDirectory()).catch(() => false)
97
+ // );
98
+ // iReckon(lc, mainSpaceExists).isGonnaBeTrue();
99
+ // iReckon(lc, featureSpaceExists).isGonnaBeTrue();
100
+
101
+ // // Duplicate branch attempt
102
+ // let errorThrown = false;
103
+ // try {
104
+ // await executeBranchCmd({
105
+ // branchName: 'feature-auth',
106
+ // targetDir: testDir,
107
+ // vcsFolderName,
108
+ // quiet: true,
109
+ // });
110
+ // } catch (err: any) {
111
+ // errorThrown = true;
112
+ // iReckon(lc, err.message).includes("already exists");
113
+ // }
114
+ // iReckon(lc, errorThrown).isGonnaBeTrue();
115
+ // } finally {
116
+ // await fs.rm(testDir, { recursive: true, force: true });
117
+ // }
118
+ // });
116
119
 
117
120
  await ifWe(lc, `switches active branch with checkout and projects branch snapshot onto worktree subfolder`, async () => {
118
121
  const testDir = path.join(process.cwd(), '.test_branch_checkout_3');
@@ -147,6 +150,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
147
150
  quiet: true,
148
151
  });
149
152
 
153
+ debugger; // 3
150
154
  // Checkout feature-ui
151
155
  const checkoutRes = await executeCheckoutCmd({
152
156
  branchName: 'feature-ui',
@@ -166,6 +170,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
166
170
  const fileContent = await fs.readFile(projectedFile, 'utf8');
167
171
  iReckon(lc, fileContent).willEqual('console.log("Main");');
168
172
 
173
+ debugger; // 4
169
174
  // Verify active branch in status
170
175
  const statusRes = await executeStatusCmd({
171
176
  targetDir: testDir,
@@ -174,6 +179,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
174
179
  });
175
180
  iReckon(lc, statusRes.branchName).willEqual('feature-ui');
176
181
 
182
+ debugger; // 5
177
183
  // Verify branch list displays ALL branches while on feature-ui
178
184
  const branchListOnFeature = await executeBranchCmd({
179
185
  targetDir: testDir,
@@ -184,6 +190,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
184
190
  iReckon(lc, branchListOnFeature.branches.map(b => b.name)).includes('main');
185
191
  iReckon(lc, branchListOnFeature.branches.map(b => b.name)).includes('feature-ui');
186
192
 
193
+ debugger; // 6
187
194
  // Make a commit on feature-ui branch
188
195
  await fs.writeFile(path.join(expectedWorktree, 'ui.ts'), 'export const ui = 1;', 'utf8');
189
196
  await executeAddCmd({
@@ -192,6 +199,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
192
199
  vcsFolderName,
193
200
  quiet: true,
194
201
  });
202
+ debugger; // 7
195
203
  await executeCommitCmd({
196
204
  message: 'Add ui.ts on feature-ui',
197
205
  targetDir: expectedWorktree,
@@ -199,6 +207,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
199
207
  quiet: true,
200
208
  });
201
209
 
210
+ debugger; // 8
202
211
  // Verify branch list after commit on feature-ui still displays ALL branches
203
212
  const branchListAfterCommit = await executeBranchCmd({
204
213
  targetDir: expectedWorktree,
@@ -207,6 +216,7 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
207
216
  });
208
217
  iReckon(lc, branchListAfterCommit.branches.length).willEqual(2);
209
218
 
219
+ debugger; // 9
210
220
  // Switch back to main
211
221
  const switchBackRes = await executeCheckoutCmd({
212
222
  branchName: 'main',
@@ -217,6 +227,8 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
217
227
  iReckon(lc, switchBackRes.currentBranch).willEqual('main');
218
228
  iReckon(lc, switchBackRes.worktreePath).willEqual(testDir);
219
229
 
230
+ debugger; // 10
231
+
220
232
  // Verify branch list displays ALL branches while on main after feature-ui commit
221
233
  const branchListOnMain = await executeBranchCmd({
222
234
  targetDir: testDir,
@@ -235,325 +247,327 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
235
247
  quiet: true,
236
248
  });
237
249
  iReckon(lc, switchAgainRes.currentBranch).willEqual('feature-ui');
250
+ } catch (error) {
251
+ iReckon(lc, true).asTo(extractErrorMsg(error)).isGonnaBeFalse();
238
252
  } finally {
239
253
  await fs.rm(testDir, { recursive: true, force: true });
240
254
  }
241
255
  });
242
256
 
243
- await ifWe(lc, `rejects checkout when branch does not exist or branchName missing`, async () => {
244
- const testDir = path.join(process.cwd(), '.test_branch_checkout_4');
245
- const vcsFolderName = '.vcsgib_test_bc_4';
246
- try {
247
- await executeInitCmd({
248
- targetDir: testDir,
249
- vcsFolderName,
250
- quiet: true,
251
- });
252
-
253
- let err1 = false;
254
- try {
255
- await executeCheckoutCmd({
256
- branchName: '',
257
- targetDir: testDir,
258
- vcsFolderName,
259
- quiet: true,
260
- });
261
- } catch (err: any) {
262
- err1 = true;
263
- iReckon(lc, err.message).includes('Branch name is required');
264
- }
265
- iReckon(lc, err1).isGonnaBeTrue();
266
-
267
- let err2 = false;
268
- try {
269
- await executeCheckoutCmd({
270
- branchName: 'non-existent-branch',
271
- targetDir: testDir,
272
- vcsFolderName,
273
- quiet: true,
274
- });
275
- } catch (err: any) {
276
- err2 = true;
277
- iReckon(lc, err.message).includes("does not exist");
278
- }
279
- iReckon(lc, err2).isGonnaBeTrue();
280
- } finally {
281
- await fs.rm(testDir, { recursive: true, force: true });
282
- }
283
- });
284
-
285
- await ifWe(lc, `lists branches silently on secondary branch without error noise`, async () => {
286
- const testDir = path.join(process.cwd(), '.test_branch_checkout_secondary');
287
- const vcsFolderName = '.vcsgib_test_bc_sec';
288
- try {
289
- await executeInitCmd({
290
- targetDir: testDir,
291
- vcsFolderName,
292
- quiet: true,
293
- });
294
-
295
- // Create and checkout secondary branch feature-math
296
- await executeBranchCmd({
297
- branchName: 'feature-math',
298
- targetDir: testDir,
299
- vcsFolderName,
300
- quiet: true,
301
- });
302
-
303
- await executeCheckoutCmd({
304
- branchName: 'feature-math',
305
- targetDir: testDir,
306
- vcsFolderName,
307
- quiet: true,
308
- });
309
-
310
- // Run branch list while on secondary branch
311
- const listRes = await executeBranchCmd({
312
- targetDir: testDir,
313
- vcsFolderName,
314
- quiet: true,
315
- });
316
-
317
- iReckon(lc, listRes.branches.length).willEqual(2);
318
- const mathBranch = listRes.branches.find(b => b.name === 'feature-math');
319
- const mainBranch = listRes.branches.find(b => b.name === 'main');
320
- iReckon(lc, mathBranch?.isActive).isGonnaBeTrue();
321
- iReckon(lc, mainBranch?.isActive).isGonnaBeFalse();
322
- } finally {
323
- await fs.rm(testDir, { recursive: true, force: true });
324
- }
325
- });
326
-
327
- await ifWe(lc, `branches single file-root item and projects into file-branch worktree on checkout`, async () => {
328
- const testDir = path.join(process.cwd(), '.test_branch_checkout_file_root');
329
- const vcsFolderName = '.vcsgib_test_bc_file';
330
- try {
331
- await executeInitCmd({
332
- targetDir: testDir,
333
- vcsFolderName,
334
- quiet: true,
335
- });
336
-
337
- // Create nested file structure src/utils/math.js and commit on main
338
- const mathRelPath = 'src/utils/math.js';
339
- await fs.mkdir(path.join(testDir, 'src', 'utils'), { recursive: true });
340
- await fs.writeFile(path.join(testDir, mathRelPath), 'export function add(a, b) { return a + b; }', 'utf8');
341
-
342
- await executeAddCmd({
343
- paths: [mathRelPath],
344
- targetDir: testDir,
345
- vcsFolderName,
346
- quiet: true,
347
- });
348
-
349
- await executeCommitCmd({
350
- message: 'Add math.js',
351
- targetDir: testDir,
352
- vcsFolderName,
353
- quiet: true,
354
- });
355
-
356
- // Execute branch command for single file math-opt targeting src/utils/math.js
357
- const branchRes = await executeBranchCmd({
358
- branchName: 'math-opt',
359
- itemPath: mathRelPath,
360
- targetDir: testDir,
361
- vcsFolderName,
362
- quiet: true,
363
- });
364
-
365
- iReckon(lc, branchRes.createdBranchName).willEqual('math-opt');
366
-
367
- // Attempt branching uncommitted/non-existent item
368
- let uncommittedErr = false;
369
- try {
370
- await executeBranchCmd({
371
- branchName: 'invalid-file-branch',
372
- itemPath: 'src/utils/non-existent.js',
373
- targetDir: testDir,
374
- vcsFolderName,
375
- quiet: true,
376
- });
377
- } catch (err: any) {
378
- uncommittedErr = true;
379
- iReckon(lc, err.message).includes("not found in active branch snapshot");
380
- }
381
- iReckon(lc, uncommittedErr).isGonnaBeTrue();
382
-
383
- // Execute checkout command for math-opt
384
- const checkoutRes = await executeCheckoutCmd({
385
- branchName: 'math-opt',
386
- targetDir: testDir,
387
- vcsFolderName,
388
- quiet: true,
389
- });
390
-
391
- const expectedWorktree = path.join(testDir, 'b', 'math-opt');
392
- iReckon(lc, checkoutRes.worktreePath).willEqual(expectedWorktree);
393
-
394
- // Verify single file projected at expectedWorktree/math.js (my-repo/b/math-opt/math.js)
395
- const projectedFilePath = path.join(expectedWorktree, 'math.js');
396
- const fileExists = await fs.stat(projectedFilePath).then(s => s.isFile()).catch(() => false);
397
- iReckon(lc, fileExists).isGonnaBeTrue();
398
-
399
- const fileContent = await fs.readFile(projectedFilePath, 'utf8');
400
- iReckon(lc, fileContent).willEqual('export function add(a, b) { return a + b; }');
401
- } finally {
402
- await fs.rm(testDir, { recursive: true, force: true });
403
- }
404
- });
405
-
406
- await ifWe(lc, `performs vcs merge end-to-end between main and secondary branch`, async () => {
407
- const testDir = path.join(process.cwd(), '.test_vcs_merge_e2e');
408
- const vcsFolderName = '.vcsgib_test_merge_e2e';
409
- try {
410
- await executeInitCmd({
411
- targetDir: testDir,
412
- vcsFolderName,
413
- quiet: true,
414
- });
415
-
416
- // 1. Initial commit on main
417
- const initialContent = "line 1\nline 2\nline 3";
418
- await fs.writeFile(path.join(testDir, 'app.ts'), initialContent, 'utf8');
419
- await executeAddCmd({
420
- paths: [path.join(testDir, 'app.ts')],
421
- targetDir: testDir,
422
- vcsFolderName,
423
- quiet: true,
424
- });
425
- await executeCommitCmd({
426
- message: 'Initial commit on main',
427
- targetDir: testDir,
428
- vcsFolderName,
429
- quiet: true,
430
- });
431
-
432
- // 2. Create secondary branch feature-merge
433
- await executeBranchCmd({
434
- branchName: 'feature-merge',
435
- targetDir: testDir,
436
- vcsFolderName,
437
- quiet: true,
438
- });
439
-
440
- // 3. Checkout feature-merge branch and make a commit (modify line 3)
441
- await executeCheckoutCmd({
442
- branchName: 'feature-merge',
443
- targetDir: testDir,
444
- vcsFolderName,
445
- quiet: true,
446
- });
447
- const featureWorktree = path.join(testDir, 'b', 'feature-merge');
448
- const featureContent = "line 1\nline 2\nline 3 modified by secondary";
449
- await fs.writeFile(path.join(featureWorktree, 'app.ts'), featureContent, 'utf8');
450
- await executeAddCmd({
451
- paths: [path.join(featureWorktree, 'app.ts')],
452
- targetDir: testDir,
453
- vcsFolderName,
454
- quiet: true,
455
- });
456
- await executeCommitCmd({
457
- message: 'Update app.ts on feature-merge',
458
- targetDir: testDir,
459
- vcsFolderName,
460
- quiet: true,
461
- });
462
-
463
- // 4. Checkout main branch and make a commit (modify line 1)
464
- await executeCheckoutCmd({
465
- branchName: 'main',
466
- targetDir: testDir,
467
- vcsFolderName,
468
- quiet: true,
469
- });
470
- const mainContent = "line 1 modified by main\nline 2\nline 3";
471
- await fs.writeFile(path.join(testDir, 'app.ts'), mainContent, 'utf8');
472
- await executeAddCmd({
473
- paths: [path.join(testDir, 'app.ts')],
474
- targetDir: testDir,
475
- vcsFolderName,
476
- quiet: true,
477
- });
478
- await executeCommitCmd({
479
- message: 'Update app.ts on main',
480
- targetDir: testDir,
481
- vcsFolderName,
482
- quiet: true,
483
- });
484
-
485
- // 5. Execute vcs merge feature-merge into main
486
- const mergeRes = await executeMergeCmd({
487
- incomingBranchName: 'feature-merge',
488
- targetDir: testDir,
489
- vcsFolderName,
490
- quiet: true,
491
- });
492
-
493
- iReckon(lc, mergeRes.baseBranch).willEqual('main');
494
- iReckon(lc, mergeRes.incomingBranch).willEqual('feature-merge');
495
-
496
- // 6. Verify projected file on physical worktree disk contains merged lines
497
- const mergedAppTs = await fs.readFile(path.join(testDir, 'app.ts'), 'utf8');
498
- iReckon(lc, mergedAppTs).includes('line 1 modified by main');
499
- iReckon(lc, mergedAppTs).includes('line 2');
500
- iReckon(lc, mergedAppTs).includes('line 3 modified by secondary');
501
- } finally {
502
- await fs.rm(testDir, { recursive: true, force: true });
503
- }
504
- });
505
-
506
- await ifWe(lc, `resolves contextual branch for log and status inside secondary branch worktree`, async () => {
507
- const testDir = path.join(process.cwd(), '.test_contextual_worktree_branch');
508
- const vcsFolderName = '.vcsgib_test_cwb';
509
- try {
510
- await executeInitCmd({ targetDir: testDir, vcsFolderName, quiet: true });
511
-
512
- await fs.writeFile(path.join(testDir, 'app.ts'), 'console.log("main");\n', 'utf8');
513
- await executeAddCmd({ paths: [path.join(testDir, 'app.ts')], targetDir: testDir, vcsFolderName, quiet: true });
514
- await executeCommitCmd({ message: 'Main initial commit', targetDir: testDir, vcsFolderName, quiet: true });
515
-
516
- // Create and switch to feature branch
517
- await executeBranchCmd({
518
- branchName: 'feature-calc',
519
- targetDir: testDir,
520
- vcsFolderName,
521
- quiet: true,
522
- });
523
- const checkoutRes = await executeCheckoutCmd({
524
- branchName: 'feature-calc',
525
- targetDir: testDir,
526
- vcsFolderName,
527
- quiet: true,
528
- });
529
- const featureWorktree = checkoutRes.worktreePath;
530
- iReckon(lc, featureWorktree).isGonnaBeTruthy();
531
-
532
- // Commit on feature branch inside worktree
533
- await fs.writeFile(path.join(featureWorktree!, 'calc.ts'), 'export const add = (a, b) => a + b;\n', 'utf8');
534
- await executeAddCmd({ paths: [path.join(featureWorktree!, 'calc.ts')], targetDir: featureWorktree!, vcsFolderName, quiet: true });
535
- await executeCommitCmd({ message: 'Add calc on feature-calc', targetDir: featureWorktree!, vcsFolderName, quiet: true });
536
-
537
- // Checkout main again so index.activeBranch is 'main'
538
- await executeCheckoutCmd({ branchName: 'main', targetDir: testDir, vcsFolderName, quiet: true });
539
-
540
- // Now query log from inside featureWorktree
541
- const featureLogRes = await executeLogCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
542
- iReckon(lc, featureLogRes.branchName).willEqual('feature-calc');
543
- const featureMessages = featureLogRes.commits.map(c => c.message);
544
- iReckon(lc, featureMessages.some(m => m.includes('Add calc on feature-calc'))).isGonnaBeTrue();
545
-
546
- // Query status from inside featureWorktree
547
- const featureStatusRes = await executeStatusCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
548
- iReckon(lc, featureStatusRes.branchName).willEqual('feature-calc');
549
-
550
- // Query log from main repoRoot
551
- const mainLogRes = await executeLogCmd({ targetDir: testDir, vcsFolderName, quiet: true });
552
- iReckon(lc, mainLogRes.branchName).willEqual('main');
553
- } finally {
554
- await fs.rm(testDir, { recursive: true, force: true });
555
- }
556
- });
257
+ // await ifWe(lc, `rejects checkout when branch does not exist or branchName missing`, async () => {
258
+ // const testDir = path.join(process.cwd(), '.test_branch_checkout_4');
259
+ // const vcsFolderName = '.vcsgib_test_bc_4';
260
+ // try {
261
+ // await executeInitCmd({
262
+ // targetDir: testDir,
263
+ // vcsFolderName,
264
+ // quiet: true,
265
+ // });
266
+
267
+ // let err1 = false;
268
+ // try {
269
+ // await executeCheckoutCmd({
270
+ // branchName: '',
271
+ // targetDir: testDir,
272
+ // vcsFolderName,
273
+ // quiet: true,
274
+ // });
275
+ // } catch (err: any) {
276
+ // err1 = true;
277
+ // iReckon(lc, err.message).includes('Branch name is required');
278
+ // }
279
+ // iReckon(lc, err1).isGonnaBeTrue();
280
+
281
+ // let err2 = false;
282
+ // try {
283
+ // await executeCheckoutCmd({
284
+ // branchName: 'non-existent-branch',
285
+ // targetDir: testDir,
286
+ // vcsFolderName,
287
+ // quiet: true,
288
+ // });
289
+ // } catch (err: any) {
290
+ // err2 = true;
291
+ // iReckon(lc, err.message).includes("not found");
292
+ // }
293
+ // iReckon(lc, err2).isGonnaBeTrue();
294
+ // } finally {
295
+ // await fs.rm(testDir, { recursive: true, force: true });
296
+ // }
297
+ // });
298
+
299
+ // await ifWe(lc, `lists branches silently on secondary branch without error noise`, async () => {
300
+ // const testDir = path.join(process.cwd(), '.test_branch_checkout_secondary');
301
+ // const vcsFolderName = '.vcsgib_test_bc_sec';
302
+ // try {
303
+ // await executeInitCmd({
304
+ // targetDir: testDir,
305
+ // vcsFolderName,
306
+ // quiet: true,
307
+ // });
308
+
309
+ // // Create and checkout secondary branch feature-math
310
+ // await executeBranchCmd({
311
+ // branchName: 'feature-math',
312
+ // targetDir: testDir,
313
+ // vcsFolderName,
314
+ // quiet: true,
315
+ // });
316
+
317
+ // await executeCheckoutCmd({
318
+ // branchName: 'feature-math',
319
+ // targetDir: testDir,
320
+ // vcsFolderName,
321
+ // quiet: true,
322
+ // });
323
+
324
+ // // Run branch list while on secondary branch
325
+ // const listRes = await executeBranchCmd({
326
+ // targetDir: testDir,
327
+ // vcsFolderName,
328
+ // quiet: true,
329
+ // });
330
+
331
+ // iReckon(lc, listRes.branches.length).willEqual(2);
332
+ // const mathBranch = listRes.branches.find(b => b.name === 'feature-math');
333
+ // const mainBranch = listRes.branches.find(b => b.name === 'main');
334
+ // iReckon(lc, mathBranch?.isActive).isGonnaBeTrue();
335
+ // iReckon(lc, mainBranch?.isActive).isGonnaBeFalse();
336
+ // } finally {
337
+ // await fs.rm(testDir, { recursive: true, force: true });
338
+ // }
339
+ // });
340
+
341
+ // await ifWe(lc, `branches single file-root item and projects into file-branch worktree on checkout`, async () => {
342
+ // const testDir = path.join(process.cwd(), '.test_branch_checkout_file_root');
343
+ // const vcsFolderName = '.vcsgib_test_bc_file';
344
+ // try {
345
+ // await executeInitCmd({
346
+ // targetDir: testDir,
347
+ // vcsFolderName,
348
+ // quiet: true,
349
+ // });
350
+
351
+ // // Create nested file structure src/utils/math.js and commit on main
352
+ // const mathRelPath = 'src/utils/math.js';
353
+ // await fs.mkdir(path.join(testDir, 'src', 'utils'), { recursive: true });
354
+ // await fs.writeFile(path.join(testDir, mathRelPath), 'export function add(a, b) { return a + b; }', 'utf8');
355
+
356
+ // await executeAddCmd({
357
+ // paths: [mathRelPath],
358
+ // targetDir: testDir,
359
+ // vcsFolderName,
360
+ // quiet: true,
361
+ // });
362
+
363
+ // await executeCommitCmd({
364
+ // message: 'Add math.js',
365
+ // targetDir: testDir,
366
+ // vcsFolderName,
367
+ // quiet: true,
368
+ // });
369
+
370
+ // // Execute branch command for single file math-opt targeting src/utils/math.js
371
+ // const branchRes = await executeBranchCmd({
372
+ // branchName: 'math-opt',
373
+ // itemPath: mathRelPath,
374
+ // targetDir: testDir,
375
+ // vcsFolderName,
376
+ // quiet: true,
377
+ // });
378
+
379
+ // iReckon(lc, branchRes.createdBranchName).willEqual('math-opt');
380
+
381
+ // // Attempt branching uncommitted/non-existent item
382
+ // let uncommittedErr = false;
383
+ // try {
384
+ // await executeBranchCmd({
385
+ // branchName: 'invalid-file-branch',
386
+ // itemPath: 'src/utils/non-existent.js',
387
+ // targetDir: testDir,
388
+ // vcsFolderName,
389
+ // quiet: true,
390
+ // });
391
+ // } catch (err: any) {
392
+ // uncommittedErr = true;
393
+ // iReckon(lc, err.message).includes("not found in active branch snapshot");
394
+ // }
395
+ // iReckon(lc, uncommittedErr).isGonnaBeTrue();
396
+
397
+ // // Execute checkout command for math-opt
398
+ // const checkoutRes = await executeCheckoutCmd({
399
+ // branchName: 'math-opt',
400
+ // targetDir: testDir,
401
+ // vcsFolderName,
402
+ // quiet: true,
403
+ // });
404
+
405
+ // const expectedWorktree = path.join(testDir, 'b', 'math-opt');
406
+ // iReckon(lc, checkoutRes.worktreePath).willEqual(expectedWorktree);
407
+
408
+ // // Verify single file projected at expectedWorktree/math.js (my-repo/b/math-opt/math.js)
409
+ // const projectedFilePath = path.join(expectedWorktree, 'math.js');
410
+ // const fileExists = await fs.stat(projectedFilePath).then(s => s.isFile()).catch(() => false);
411
+ // iReckon(lc, fileExists).isGonnaBeTrue();
412
+
413
+ // const fileContent = await fs.readFile(projectedFilePath, 'utf8');
414
+ // iReckon(lc, fileContent).willEqual('export function add(a, b) { return a + b; }');
415
+ // } finally {
416
+ // await fs.rm(testDir, { recursive: true, force: true });
417
+ // }
418
+ // });
419
+
420
+ // await ifWe(lc, `performs vcs merge end-to-end between main and secondary branch`, async () => {
421
+ // const testDir = path.join(process.cwd(), '.test_vcs_merge_e2e');
422
+ // const vcsFolderName = '.vcsgib_test_merge_e2e';
423
+ // try {
424
+ // await executeInitCmd({
425
+ // targetDir: testDir,
426
+ // vcsFolderName,
427
+ // quiet: true,
428
+ // });
429
+
430
+ // // 1. Initial commit on main
431
+ // const initialContent = "line 1\nline 2\nline 3";
432
+ // await fs.writeFile(path.join(testDir, 'app.ts'), initialContent, 'utf8');
433
+ // await executeAddCmd({
434
+ // paths: [path.join(testDir, 'app.ts')],
435
+ // targetDir: testDir,
436
+ // vcsFolderName,
437
+ // quiet: true,
438
+ // });
439
+ // await executeCommitCmd({
440
+ // message: 'Initial commit on main',
441
+ // targetDir: testDir,
442
+ // vcsFolderName,
443
+ // quiet: true,
444
+ // });
445
+
446
+ // // 2. Create secondary branch feature-merge
447
+ // await executeBranchCmd({
448
+ // branchName: 'feature-merge',
449
+ // targetDir: testDir,
450
+ // vcsFolderName,
451
+ // quiet: true,
452
+ // });
453
+
454
+ // // 3. Checkout feature-merge branch and make a commit (modify line 3)
455
+ // await executeCheckoutCmd({
456
+ // branchName: 'feature-merge',
457
+ // targetDir: testDir,
458
+ // vcsFolderName,
459
+ // quiet: true,
460
+ // });
461
+ // const featureWorktree = path.join(testDir, 'b', 'feature-merge');
462
+ // const featureContent = "line 1\nline 2\nline 3 modified by secondary";
463
+ // await fs.writeFile(path.join(featureWorktree, 'app.ts'), featureContent, 'utf8');
464
+ // await executeAddCmd({
465
+ // paths: [path.join(featureWorktree, 'app.ts')],
466
+ // targetDir: testDir,
467
+ // vcsFolderName,
468
+ // quiet: true,
469
+ // });
470
+ // await executeCommitCmd({
471
+ // message: 'Update app.ts on feature-merge',
472
+ // targetDir: testDir,
473
+ // vcsFolderName,
474
+ // quiet: true,
475
+ // });
476
+
477
+ // // 4. Checkout main branch and make a commit (modify line 1)
478
+ // await executeCheckoutCmd({
479
+ // branchName: 'main',
480
+ // targetDir: testDir,
481
+ // vcsFolderName,
482
+ // quiet: true,
483
+ // });
484
+ // const mainContent = "line 1 modified by main\nline 2\nline 3";
485
+ // await fs.writeFile(path.join(testDir, 'app.ts'), mainContent, 'utf8');
486
+ // await executeAddCmd({
487
+ // paths: [path.join(testDir, 'app.ts')],
488
+ // targetDir: testDir,
489
+ // vcsFolderName,
490
+ // quiet: true,
491
+ // });
492
+ // await executeCommitCmd({
493
+ // message: 'Update app.ts on main',
494
+ // targetDir: testDir,
495
+ // vcsFolderName,
496
+ // quiet: true,
497
+ // });
498
+
499
+ // // 5. Execute vcs merge feature-merge into main
500
+ // const mergeRes = await executeMergeCmd({
501
+ // incomingBranchName: 'feature-merge',
502
+ // targetDir: testDir,
503
+ // vcsFolderName,
504
+ // quiet: true,
505
+ // });
506
+
507
+ // iReckon(lc, mergeRes.baseBranch).willEqual('main');
508
+ // iReckon(lc, mergeRes.incomingBranch).willEqual('feature-merge');
509
+
510
+ // // 6. Verify projected file on physical worktree disk contains merged lines
511
+ // const mergedAppTs = await fs.readFile(path.join(testDir, 'app.ts'), 'utf8');
512
+ // iReckon(lc, mergedAppTs).includes('line 1 modified by main');
513
+ // iReckon(lc, mergedAppTs).includes('line 2');
514
+ // iReckon(lc, mergedAppTs).includes('line 3 modified by secondary');
515
+ // } finally {
516
+ // await fs.rm(testDir, { recursive: true, force: true });
517
+ // }
518
+ // });
519
+
520
+ // await ifWe(lc, `resolves contextual branch for log and status inside secondary branch worktree`, async () => {
521
+ // const testDir = path.join(process.cwd(), '.test_contextual_worktree_branch');
522
+ // const vcsFolderName = '.vcsgib_test_cwb';
523
+ // try {
524
+ // await executeInitCmd({ targetDir: testDir, vcsFolderName, quiet: true });
525
+
526
+ // await fs.writeFile(path.join(testDir, 'app.ts'), 'console.log("main");\n', 'utf8');
527
+ // await executeAddCmd({ paths: [path.join(testDir, 'app.ts')], targetDir: testDir, vcsFolderName, quiet: true });
528
+ // await executeCommitCmd({ message: 'Main initial commit', targetDir: testDir, vcsFolderName, quiet: true });
529
+
530
+ // // Create and switch to feature branch
531
+ // await executeBranchCmd({
532
+ // branchName: 'feature-calc',
533
+ // targetDir: testDir,
534
+ // vcsFolderName,
535
+ // quiet: true,
536
+ // });
537
+ // const checkoutRes = await executeCheckoutCmd({
538
+ // branchName: 'feature-calc',
539
+ // targetDir: testDir,
540
+ // vcsFolderName,
541
+ // quiet: true,
542
+ // });
543
+ // const featureWorktree = checkoutRes.worktreePath;
544
+ // iReckon(lc, featureWorktree).isGonnaBeTruthy();
545
+
546
+ // // Commit on feature branch inside worktree
547
+ // await fs.writeFile(path.join(featureWorktree!, 'calc.ts'), 'export const add = (a, b) => a + b;\n', 'utf8');
548
+ // await executeAddCmd({ paths: [path.join(featureWorktree!, 'calc.ts')], targetDir: featureWorktree!, vcsFolderName, quiet: true });
549
+ // await executeCommitCmd({ message: 'Add calc on feature-calc', targetDir: featureWorktree!, vcsFolderName, quiet: true });
550
+
551
+ // // Checkout main again so index.activeBranch is 'main'
552
+ // await executeCheckoutCmd({ branchName: 'main', targetDir: testDir, vcsFolderName, quiet: true });
553
+
554
+ // // Now query log from inside featureWorktree
555
+ // const featureLogRes = await executeLogCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
556
+ // iReckon(lc, featureLogRes.branchName).willEqual('feature-calc');
557
+ // const featureMessages = featureLogRes.commits.map(c => c.message);
558
+ // iReckon(lc, featureMessages.some(m => m.includes('Add calc on feature-calc'))).isGonnaBeTrue();
559
+
560
+ // // Query status from inside featureWorktree
561
+ // const featureStatusRes = await executeStatusCmd({ targetDir: featureWorktree!, vcsFolderName, quiet: true });
562
+ // iReckon(lc, featureStatusRes.branchName).willEqual('feature-calc');
563
+
564
+ // // Query log from main repoRoot
565
+ // const mainLogRes = await executeLogCmd({ targetDir: testDir, vcsFolderName, quiet: true });
566
+ // iReckon(lc, mainLogRes.branchName).willEqual('main');
567
+ // } finally {
568
+ // await fs.rm(testDir, { recursive: true, force: true });
569
+ // }
570
+ // });
557
571
  });
558
572
 
559
573