mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-01 02:01:24 +00:00
test(storage): pin shared-store behavior for worktrees of a bare repository (#3374)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d0894ae4b7
commit
0d97f74545
1 changed files with 34 additions and 0 deletions
|
|
@ -340,3 +340,37 @@ describe('slot naming edge cases (#3352 review)', () => {
|
|||
expect(resolveGraphPath(layout.checkoutSlot)).toBe(graph);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bare repositories (#3352 review)', () => {
|
||||
it('shares worktrees of a bare repository, keyed by the bare dir, with no main checkout', async () => {
|
||||
const parent = await makeTempDir('gn-shared-bare-');
|
||||
const src = path.join(parent, 'src');
|
||||
await fs.mkdir(src);
|
||||
git(src, 'init', '-q', '-b', 'main');
|
||||
git(
|
||||
src,
|
||||
'-c',
|
||||
'user.email=t@t',
|
||||
'-c',
|
||||
'user.name=t',
|
||||
'commit',
|
||||
'-q',
|
||||
'--allow-empty',
|
||||
'-m',
|
||||
'init',
|
||||
);
|
||||
const bare = path.join(parent, 'repo.git');
|
||||
git(parent, 'clone', '-q', '--bare', src, bare);
|
||||
const wtA = path.join(parent, 'wt-a');
|
||||
const wtB = path.join(parent, 'wt-b');
|
||||
git(bare, 'worktree', 'add', '-q', '-b', 'a', wtA);
|
||||
git(bare, 'worktree', 'add', '-q', '-b', 'b', wtB);
|
||||
|
||||
const a = layoutOf(wtA);
|
||||
expect(layoutOf(wtB).root).toBe(a.root);
|
||||
expect(a.key).toMatch(/^repo\.git-[0-9a-f]{12}$/);
|
||||
expect(a.canonicalCheckout).toBeNull();
|
||||
// The bare dir itself has no working tree to analyze.
|
||||
expect(resolveSharedStoreKey(bare, cleanEnv())).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue