@ibgib/vcs-gib 0.0.26 → 0.0.30
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/CHANGELOG.md +3 -0
- package/dist/AUTO-GENERATED-version.d.mts +1 -1
- package/dist/AUTO-GENERATED-version.mjs +1 -1
- package/dist/cli/commands/add-cmd.d.mts.map +1 -1
- package/dist/cli/commands/add-cmd.mjs +6 -1
- package/dist/cli/commands/add-cmd.mjs.map +1 -1
- package/dist/cli/commands/commit-cmd.d.mts.map +1 -1
- package/dist/cli/commands/commit-cmd.mjs +6 -2
- package/dist/cli/commands/commit-cmd.mjs.map +1 -1
- package/dist/cli/commands/log-cmd.d.mts.map +1 -1
- package/dist/cli/commands/log-cmd.mjs +6 -1
- package/dist/cli/commands/log-cmd.mjs.map +1 -1
- package/dist/cli/commands/status-cmd.d.mts.map +1 -1
- package/dist/cli/commands/status-cmd.mjs +1 -0
- package/dist/cli/commands/status-cmd.mjs.map +1 -1
- package/dist/engine/branch/branch-helper.d.mts +14 -0
- package/dist/engine/branch/branch-helper.d.mts.map +1 -1
- package/dist/engine/branch/branch-helper.mjs +21 -0
- package/dist/engine/branch/branch-helper.mjs.map +1 -1
- package/dist/engine/status/status-helper.d.mts +2 -1
- package/dist/engine/status/status-helper.d.mts.map +1 -1
- package/dist/engine/status/status-helper.mjs +3 -2
- package/dist/engine/status/status-helper.mjs.map +1 -1
- package/package.json +3 -3
- package/src/AUTO-GENERATED-version.mts +1 -1
- package/src/cli/commands/add-cmd.mts +6 -1
- package/src/cli/commands/branch-checkout-cmd.respec.mts +54 -0
- package/src/cli/commands/commit-cmd.mts +6 -2
- package/src/cli/commands/log-cmd.mts +6 -1
- package/src/cli/commands/status-cmd.mts +1 -0
- package/src/engine/branch/branch-helper.mts +33 -0
- package/src/engine/status/status-helper.mts +4 -1
- package/tsconfig.test.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -19,6 +19,7 @@ import { executeBranchCmd } from './branch-cmd.mjs';
|
|
|
19
19
|
import { executeCheckoutCmd } from './checkout-cmd.mjs';
|
|
20
20
|
import { executeMergeCmd } from './merge-cmd.mjs';
|
|
21
21
|
import { executeStatusCmd } from './status-cmd.mjs';
|
|
22
|
+
import { executeLogCmd } from './log-cmd.mjs';
|
|
22
23
|
import { logCheckpoint } from '../../test/test-helpers.mjs';
|
|
23
24
|
|
|
24
25
|
const lc = `[apps/vcs-gib/src/cli/commands/branch-checkout-cmd.respec.node.mts]`;
|
|
@@ -501,5 +502,58 @@ await respecfully(lc, `vcs branch, checkout, and merge Command Handlers`, async
|
|
|
501
502
|
await fs.rm(testDir, { recursive: true, force: true });
|
|
502
503
|
}
|
|
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
|
+
});
|
|
504
557
|
});
|
|
505
558
|
|
|
559
|
+
|
|
@@ -25,7 +25,7 @@ import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
|
25
25
|
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
26
26
|
import { B2tFSItemIbGib_V1, B2TFS_CHILD_ITEM_REL8N_NAME } from '../../engine/item/item-types.mjs';
|
|
27
27
|
import { getIbGibWithMetaspaceFallback, createB2tFSItemIbGib, evolveB2tFSItemIbGib } from '../../engine/item/item-helper.mjs';
|
|
28
|
-
import { getB2tFSBranchSpaceName } from '../../engine/branch/branch-helper.mjs';
|
|
28
|
+
import { getB2tFSBranchSpaceName, resolveContextualBranchName } from '../../engine/branch/branch-helper.mjs';
|
|
29
29
|
import { B2tFSBranchIbGib_V1 } from '../../engine/branch/branch-types.mjs';
|
|
30
30
|
import { getB2tFSIndexIbGib, updateB2tFSIndexIbGib, getSpaceQualifiedIbGibAddr } from '../../engine/index/index-helper.mjs';
|
|
31
31
|
import { B2tFSStagedItemRecord } from '../../engine/index/index-types.mjs';
|
|
@@ -85,7 +85,11 @@ export async function executeCommitCmd({
|
|
|
85
85
|
throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f)`);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const branchName =
|
|
88
|
+
const branchName = resolveContextualBranchName({
|
|
89
|
+
targetDir: absTargetDir,
|
|
90
|
+
repoRoot,
|
|
91
|
+
indexIbGib,
|
|
92
|
+
});
|
|
89
93
|
const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
|
|
90
94
|
|
|
91
95
|
// Target active branch space b2s_<activeBranch>
|
|
@@ -15,6 +15,7 @@ import { CommentIbGib_V1 } from '@ibgib/core-gib/dist/common/comment/comment-typ
|
|
|
15
15
|
|
|
16
16
|
import { bootstrapVcsMetaspace } from '../../bootstrap/node-bootstrap.mjs';
|
|
17
17
|
import { getOrCreateBranchSpace } from '../../engine/branch/branch-space-helper.mjs';
|
|
18
|
+
import { resolveContextualBranchName } from '../../engine/branch/branch-helper.mjs';
|
|
18
19
|
import { getIbGibWithMetaspaceFallback } from '../../engine/item/item-helper.mjs';
|
|
19
20
|
import { B2tFSItemIbGib_V1, B2TFS_CHILD_ITEM_REL8N_NAME } from '../../engine/item/item-types.mjs';
|
|
20
21
|
import { B2tFSBranchIbGib_V1 } from '../../engine/branch/branch-types.mjs';
|
|
@@ -84,7 +85,11 @@ export async function executeLogCmd({
|
|
|
84
85
|
throw new Error(`Repository index B2tFSIndexIbGib_V1 not found in localSpace (E: 3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a)`);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
const branchName =
|
|
88
|
+
const branchName = resolveContextualBranchName({
|
|
89
|
+
targetDir: absTargetDir,
|
|
90
|
+
repoRoot,
|
|
91
|
+
indexIbGib,
|
|
92
|
+
});
|
|
88
93
|
|
|
89
94
|
// Target active branch space b2s_<activeBranch>
|
|
90
95
|
const { space: activeSpace } = await getOrCreateBranchSpace({
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and branch timeline tracking.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import path from 'node:path';
|
|
8
9
|
import { getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
9
10
|
import { ROOT } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
10
11
|
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
@@ -77,3 +78,35 @@ export async function createB2tFSBranchIbGib(opts: {
|
|
|
77
78
|
|
|
78
79
|
return branchIbGib;
|
|
79
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Resolves the contextual branch name given the target directory and repository root.
|
|
84
|
+
* If targetDir is physically located inside a secondary branch worktree (`repoRoot/b/<branchName>`),
|
|
85
|
+
* that worktree's branchName is returned. Otherwise, the index's activeBranch (defaulting to 'main') is returned.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveContextualBranchName({
|
|
88
|
+
targetDir,
|
|
89
|
+
repoRoot,
|
|
90
|
+
indexIbGib,
|
|
91
|
+
}: {
|
|
92
|
+
targetDir: string;
|
|
93
|
+
repoRoot: string;
|
|
94
|
+
indexIbGib?: { data?: { activeBranch?: string } } | null;
|
|
95
|
+
}): string {
|
|
96
|
+
const absTarget = path.resolve(targetDir);
|
|
97
|
+
const absRoot = path.resolve(repoRoot);
|
|
98
|
+
const rel = path.relative(absRoot, absTarget).replace(/\\/g, '/');
|
|
99
|
+
|
|
100
|
+
if (rel.startsWith('b/') || rel === 'b') {
|
|
101
|
+
const parts = rel.split('/').filter(Boolean);
|
|
102
|
+
if (parts.length >= 2 && parts[0] === 'b') {
|
|
103
|
+
const candidateBranch = parts[1];
|
|
104
|
+
if (candidateBranch) {
|
|
105
|
+
return candidateBranch;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return indexIbGib?.data?.activeBranch || 'main';
|
|
111
|
+
}
|
|
112
|
+
|
|
@@ -16,6 +16,7 @@ import { isPathFiltered, parseFilterFileContent } from '../filter/glob-helper.mj
|
|
|
16
16
|
import { getB2tFSIndexIbGib } from '../index/index-helper.mjs';
|
|
17
17
|
import { B2tFSStagedItemRecord } from '../index/index-types.mjs';
|
|
18
18
|
import { getOrCreateBranchSpace } from '../branch/branch-space-helper.mjs';
|
|
19
|
+
import { resolveContextualBranchName } from '../branch/branch-helper.mjs';
|
|
19
20
|
|
|
20
21
|
export interface VcsStatusItem {
|
|
21
22
|
path: string;
|
|
@@ -194,16 +195,18 @@ export async function getRepoStatus({
|
|
|
194
195
|
localSpace,
|
|
195
196
|
vcsPath,
|
|
196
197
|
repoRoot,
|
|
198
|
+
targetDir = repoRoot,
|
|
197
199
|
vcsFolderName = '.vcsgib',
|
|
198
200
|
}: {
|
|
199
201
|
metaspace: any;
|
|
200
202
|
localSpace: any;
|
|
201
203
|
vcsPath: string;
|
|
202
204
|
repoRoot: string;
|
|
205
|
+
targetDir?: string;
|
|
203
206
|
vcsFolderName?: string;
|
|
204
207
|
}): Promise<RepoStatusResult> {
|
|
205
208
|
const indexIbGib = await getB2tFSIndexIbGib({ space: localSpace, vcsPath });
|
|
206
|
-
const branchName = indexIbGib
|
|
209
|
+
const branchName = resolveContextualBranchName({ targetDir, repoRoot, indexIbGib });
|
|
207
210
|
const activeWorktreeDir = branchName === 'main' ? repoRoot : path.join(repoRoot, 'b', branchName);
|
|
208
211
|
|
|
209
212
|
const { space: activeBranchSpace } = await getOrCreateBranchSpace({
|