pi-odd-worktree 2.0.0 → 3.0.0
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/README.md +54 -311
- package/extensions/odd-worktree-tools.ts +4149 -2447
- package/lib/bash-activity.js +1164 -0
- package/lib/bash-design.js +684 -0
- package/lib/bash-destructive.js +559 -0
- package/lib/bash-frame.js +205 -0
- package/lib/card-content.js +23 -0
- package/lib/card-style.js +175 -0
- package/lib/checkout-facts.js +30 -70
- package/lib/codegraph-card-preview.js +628 -0
- package/lib/codegraph-card.js +515 -0
- package/lib/codegraph-compaction.js +76 -0
- package/lib/codegraph-daemon.js +246 -0
- package/lib/codegraph-edit-sync.js +182 -0
- package/lib/codegraph-guard-target.js +337 -0
- package/lib/codegraph-guard.js +211 -0
- package/lib/codegraph-index.js +1020 -0
- package/lib/codegraph-lock.js +607 -0
- package/lib/codegraph-mcp-config.js +134 -0
- package/lib/codegraph-mcp.js +123 -0
- package/lib/codegraph-paths.js +69 -0
- package/lib/codegraph-prompt/explore.md +11 -0
- package/lib/codegraph-prompt/fix.md +6 -0
- package/lib/codegraph-prompt/generic.md +8 -0
- package/lib/codegraph-prompt/judge.md +9 -0
- package/lib/codegraph-prompt/orchestrator.md +17 -0
- package/lib/codegraph-prompt/verify.md +10 -0
- package/lib/codegraph-prompt/worker.md +7 -0
- package/lib/codegraph-role.js +55 -0
- package/lib/codegraph-rules.js +146 -0
- package/lib/codegraph-session.js +303 -383
- package/lib/codegraph-warmup.js +139 -0
- package/lib/file-card-markdown.js +141 -0
- package/lib/file-card-resolver.js +245 -0
- package/lib/file-card.js +659 -0
- package/lib/files-index.js +387 -0
- package/lib/files-insert.js +81 -0
- package/lib/files-orders.js +326 -0
- package/lib/files-picker-view.js +1416 -0
- package/lib/files-preview.js +338 -0
- package/lib/files-scope-detail.js +171 -0
- package/lib/files-scope-view.js +507 -0
- package/lib/gh-issues.js +308 -14
- package/lib/issue-preview.js +26 -7
- package/lib/issues-bash-mutation.js +206 -0
- package/lib/issues-cache-store.js +261 -0
- package/lib/issues-section.js +710 -0
- package/lib/issues-view.js +649 -52
- package/lib/odd-prompt/odd-worktrees.md +21 -0
- package/lib/odd-worktrees-prompt.js +10 -28
- package/lib/related-issues-cache.js +210 -0
- package/lib/shell-card.js +825 -0
- package/lib/skill-odd-card.js +183 -0
- package/lib/tui-paint.js +4 -5
- package/lib/warp-create-panel.js +538 -250
- package/lib/warp-create-picker.js +56 -9
- package/lib/warp-delete-confirm.js +19 -28
- package/lib/warp-selector-view.js +160 -82
- package/lib/which-command.js +90 -0
- package/lib/worktree-card.js +267 -897
- package/lib/worktree-cards.js +383 -0
- package/lib/worktree-create.js +287 -0
- package/lib/worktree-git.js +3 -3
- package/lib/worktree-guard.js +548 -0
- package/lib/worktree-hooks.js +421 -711
- package/lib/worktree-list.js +120 -0
- package/lib/worktree-registry.js +162 -879
- package/lib/{worktree-close-herdr.js → worktree-remove.js} +9 -11
- package/lib/worktree-setup-runner.js +376 -0
- package/lib/worktree-setup.js +140 -0
- package/lib/worktree-warp-busy.js +462 -85
- package/lib/worktree-warp-sessions.js +1 -2
- package/package.json +2 -2
- package/tools/bash-activity.test.js +1419 -0
- package/tools/bash-design.test.js +1091 -0
- package/tools/bash-destructive.test.js +139 -0
- package/tools/card-content.test.js +44 -0
- package/tools/card-style.test.js +298 -0
- package/tools/codegraph-card-preview.test.js +254 -0
- package/tools/codegraph-card.test.js +1080 -0
- package/tools/codegraph-compaction.test.js +378 -0
- package/tools/codegraph-daemon.test.js +248 -0
- package/tools/codegraph-edit-sync.test.js +295 -0
- package/tools/codegraph-guard-target.test.js +174 -0
- package/tools/codegraph-guard.test.js +238 -0
- package/tools/codegraph-index.test.js +1948 -0
- package/tools/codegraph-lock.test.js +932 -0
- package/tools/codegraph-mcp-config.test.js +181 -0
- package/tools/codegraph-mcp.test.js +194 -0
- package/tools/codegraph-paths.test.js +44 -0
- package/tools/codegraph-role.test.js +30 -0
- package/tools/codegraph-rules.test.js +250 -0
- package/tools/codegraph-session.test.js +660 -391
- package/tools/codegraph-warmup.test.js +316 -0
- package/tools/commands.test.js +510 -31
- package/tools/file-card-markdown.test.js +188 -0
- package/tools/file-card.test.js +1289 -0
- package/tools/files-bridge.test.js +575 -0
- package/tools/files-command.test.js +610 -0
- package/tools/files-index.test.js +473 -0
- package/tools/files-insert.test.js +139 -0
- package/tools/files-orders.test.js +597 -0
- package/tools/files-picker-view.test.js +1871 -0
- package/tools/files-preview.test.js +452 -0
- package/tools/files-scope-detail.test.js +264 -0
- package/tools/files-scope-view.test.js +614 -0
- package/tools/fixtures/card-codegraph-outputs.js +110 -0
- package/tools/fixtures/codegraph-cli-stub.js +16 -0
- package/tools/fixtures/codegraph-init-process.js +28 -0
- package/tools/fixtures/codegraph-lock-worker.js +117 -0
- package/tools/fixtures/daemon-fake.js +98 -0
- package/tools/fixtures/daemon-mcp-server.js +39 -0
- package/tools/fixtures/daemon-warmup-worker.js +12 -0
- package/tools/fixtures/load-extension.js +136 -3
- package/tools/gh-issues-feedback.test.js +31 -7
- package/tools/gh-issues.test.js +391 -1
- package/tools/issue-preview.test.js +44 -7
- package/tools/issues-bash-mutation.test.js +101 -0
- package/tools/issues-cache-store.test.js +222 -0
- package/tools/issues-command.test.js +1512 -66
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4195 -0
- package/tools/issues-seed-query-regression.test.js +67 -0
- package/tools/issues-view.test.js +1489 -60
- package/tools/odd-worktrees-prompt.test.js +98 -65
- package/tools/package-surface.test.js +431 -36
- package/tools/related-issues-cache.test.js +324 -0
- package/tools/shell-card.test.js +834 -0
- package/tools/skill-odd-card.test.js +200 -0
- package/tools/t5-session-identity.test.js +44 -22
- package/tools/warp-busy-guard.test.js +2569 -308
- package/tools/warp-create-panel.test.js +499 -74
- package/tools/warp-create-picker.test.js +101 -5
- package/tools/warp-delete-confirm.test.js +49 -15
- package/tools/warp-empty-session.test.js +0 -1
- package/tools/warp-fallback-regression.test.js +533 -0
- package/tools/warp-selector-view.test.js +460 -196
- package/tools/which-command.test.js +126 -0
- package/tools/worktree-card.test.js +551 -0
- package/tools/worktree-cards.test.js +845 -0
- package/tools/worktree-changes.test.js +4 -5
- package/tools/worktree-create.test.js +489 -0
- package/tools/worktree-guard.test.js +823 -0
- package/tools/worktree-hooks.test.js +905 -0
- package/tools/worktree-list.test.js +170 -0
- package/tools/worktree-registry.test.js +89 -230
- package/tools/worktree-remove-async.test.js +318 -0
- package/tools/worktree-setup-runner.test.js +276 -0
- package/tools/worktree-setup.test.js +140 -0
- package/tools/worktree-tools.test.js +477 -93
- package/lib/codegraph-commands.js +0 -165
- package/lib/odd-prompt/odd-worktrees.with-codegraph.md +0 -19
- package/lib/odd-prompt/odd-worktrees.without-codegraph.md +0 -15
- package/lib/worktree-model-result.js +0 -291
- package/tools/codegraph-commands.test.js +0 -371
- package/tools/herdr-free-create.test.js +0 -161
- package/tools/worktree-close-herdr-async.test.js +0 -204
- package/tools/worktree-odd-migration.test.js +0 -224
- package/tools/worktree-registry-cache.test.js +0 -163
- package/tools/worktree-registry-odd.test.js +0 -231
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// T1 (files-picker S6, S13, S16) tests: lib/files-index.js — the Git listing,
|
|
3
|
+
// each file's change state with its age, and the bounded preview reader.
|
|
4
|
+
//
|
|
5
|
+
// The public surface only: the exact argv the injected runner receives, the
|
|
6
|
+
// classification of untracked / dirty / clean (a .gitignore'd file never
|
|
7
|
+
// appears because Git is asked for the standard exclude set), the recency order
|
|
8
|
+
// and the age labels, and the preview's text / truncation / binary / error paths
|
|
9
|
+
// against real temporary files. No child process is spawned and no network is
|
|
10
|
+
// touched: every Git read goes through the fake runner below, and the temporary
|
|
11
|
+
// directories live under os.tmpdir() and are removed in after().
|
|
12
|
+
|
|
13
|
+
const { test, after } = require('node:test');
|
|
14
|
+
const assert = require('node:assert/strict');
|
|
15
|
+
const fs = require('node:fs');
|
|
16
|
+
const os = require('node:os');
|
|
17
|
+
const path = require('node:path');
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
listRepositoryEntries,
|
|
21
|
+
listRepositoryFiles,
|
|
22
|
+
readFilePreview,
|
|
23
|
+
formatAge,
|
|
24
|
+
FILE_PREVIEW_LIMITS,
|
|
25
|
+
FILE_PREVIEW_BINARY_NOTICE,
|
|
26
|
+
} = require('../lib/files-index.js');
|
|
27
|
+
|
|
28
|
+
const LIST_ARGV = ['ls-files', '-z', '--cached', '--others', '--exclude-standard'];
|
|
29
|
+
const STATUS_ARGV = ['--no-optional-locks', 'status', '--porcelain=v1', '-z', '--untracked-files=all'];
|
|
30
|
+
const ROOT_ARGV = ['rev-parse', '--show-toplevel'];
|
|
31
|
+
|
|
32
|
+
const MINUTE = 60_000;
|
|
33
|
+
const HOUR = 3_600_000;
|
|
34
|
+
const DAY = 86_400_000;
|
|
35
|
+
|
|
36
|
+
const scratch = [];
|
|
37
|
+
|
|
38
|
+
function tempDir() {
|
|
39
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'files-index-'));
|
|
40
|
+
scratch.push(dir);
|
|
41
|
+
return dir;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
after(() => {
|
|
45
|
+
for (const dir of scratch) fs.rmSync(dir, { recursive: true, force: true });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function writeFile(root, relativePath, content) {
|
|
49
|
+
const full = path.join(root, relativePath);
|
|
50
|
+
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
51
|
+
fs.writeFileSync(full, content);
|
|
52
|
+
return full;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function setMtime(full, mtimeMs) {
|
|
56
|
+
fs.utimesSync(full, new Date(mtimeMs), new Date(mtimeMs));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// The seam: `run(args, opts)` answering the `runArgvAsync` result shape, with
|
|
60
|
+
// every call recorded so a test can state the argv and the options it saw.
|
|
61
|
+
function fakeRunner(answer) {
|
|
62
|
+
const calls = [];
|
|
63
|
+
const run = async (args, opts) => {
|
|
64
|
+
calls.push({ args: [...args], opts });
|
|
65
|
+
const reply = answer(args, opts, calls.length);
|
|
66
|
+
if (reply instanceof Error) throw reply;
|
|
67
|
+
return reply;
|
|
68
|
+
};
|
|
69
|
+
return { run, calls };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function gitAnswer({ listing = '', status = '', root } = {}) {
|
|
73
|
+
return (args) => {
|
|
74
|
+
if (args[0] === 'ls-files') return { status: 0, stdout: listing, stderr: '' };
|
|
75
|
+
if (args[0] === '--no-optional-locks') return { status: 0, stdout: status, stderr: '' };
|
|
76
|
+
if (args[0] === 'rev-parse') {
|
|
77
|
+
return { status: root === undefined ? 128 : 0, stdout: root === undefined ? '' : `${root}\n`, stderr: '' };
|
|
78
|
+
}
|
|
79
|
+
return { status: 1, stdout: '', stderr: 'unexpected argv' };
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function pairs(entries) {
|
|
84
|
+
return entries.map((entry) => [entry.path, entry.state]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// --- the listing -----------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
test('the listing is one fixed git ls-files argv asking for stdin-free, unquoted paths', async () => {
|
|
90
|
+
const { run, calls } = fakeRunner(() => ({ status: 0, stdout: 'b.js\0a.ts\0b.js\0', stderr: '' }));
|
|
91
|
+
|
|
92
|
+
const listed = await listRepositoryFiles({ run, cwd: '/repo' });
|
|
93
|
+
|
|
94
|
+
assert.deepEqual(listed, { ok: true, files: ['a.ts', 'b.js'] }, 'duplicates collapse and paths sort by code unit');
|
|
95
|
+
assert.equal(calls.length, 1, 'one bounded process, not one per file');
|
|
96
|
+
assert.deepEqual(calls[0].args, LIST_ARGV);
|
|
97
|
+
assert.equal(calls[0].opts.cwd, '/repo');
|
|
98
|
+
assert.equal(typeof calls[0].opts.timeoutMs, 'number');
|
|
99
|
+
assert.ok(calls[0].opts.timeoutMs > 0 && calls[0].opts.timeoutMs <= 60_000, 'every git read is bounded');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('a .gitignore\'d file is absent: Git is asked for the tracked files plus the not-ignored ones', async () => {
|
|
103
|
+
// Git answers the listing below: the tracked file, the untracked one it does
|
|
104
|
+
// not ignore, and NOT dist/bundle.js, which .gitignore covers. That answer is
|
|
105
|
+
// the whole .gitignore contract — the module never parses the ignore file.
|
|
106
|
+
const { run, calls } = fakeRunner(() => ({ status: 0, stdout: 'src/a.ts\0notes.txt\0', stderr: '' }));
|
|
107
|
+
|
|
108
|
+
const listed = await listRepositoryFiles({ run, cwd: '/repo' });
|
|
109
|
+
|
|
110
|
+
assert.deepEqual(listed, { ok: true, files: ['notes.txt', 'src/a.ts'] });
|
|
111
|
+
assert.ok(listed.files.every((file) => file !== 'dist/bundle.js'), 'the ignored file is not in the list');
|
|
112
|
+
assert.ok(calls[0].args.includes('--others'), 'untracked files are listed');
|
|
113
|
+
assert.ok(calls[0].args.includes('--exclude-standard'), 'untracked-but-ignored files are not');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('an empty repository is a success with no file', async () => {
|
|
117
|
+
const { run } = fakeRunner(() => ({ status: 0, stdout: '', stderr: '' }));
|
|
118
|
+
assert.deepEqual(await listRepositoryFiles({ run, cwd: '/repo' }), { ok: true, files: [] });
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('a failed listing is a failure sentence, never an empty success', async () => {
|
|
122
|
+
const { run } = fakeRunner(() => ({ status: 1, stdout: '', stderr: 'fatal: bad revision\nsecond line' }));
|
|
123
|
+
|
|
124
|
+
assert.deepEqual(await listRepositoryFiles({ run, cwd: '/repo' }), {
|
|
125
|
+
ok: false,
|
|
126
|
+
message: 'Cannot list repository files: fatal: bad revision.',
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('outside a Git repository the sentence a panel paints says exactly that', async () => {
|
|
131
|
+
const { run } = fakeRunner(() => ({
|
|
132
|
+
status: 128,
|
|
133
|
+
stdout: '',
|
|
134
|
+
stderr: 'fatal: not a git repository (or any of the parent directories): .git',
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
assert.deepEqual(await listRepositoryFiles({ run, cwd: '/tmp/not-a-repo' }), {
|
|
138
|
+
ok: false,
|
|
139
|
+
message: 'Not a Git repository: /tmp/not-a-repo.',
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('a runner that rejects and one that answers a spawn error both become sentences', async () => {
|
|
144
|
+
const rejected = fakeRunner(() => new Error('boom'));
|
|
145
|
+
assert.deepEqual(await listRepositoryFiles({ run: rejected.run, cwd: '/repo' }), {
|
|
146
|
+
ok: false,
|
|
147
|
+
message: 'Cannot list repository files: boom.',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const unspawnable = fakeRunner(() => ({ status: null, stdout: '', stderr: '', error: 'spawn git ENOENT' }));
|
|
151
|
+
assert.deepEqual(await listRepositoryFiles({ run: unspawnable.run, cwd: '/repo' }), {
|
|
152
|
+
ok: false,
|
|
153
|
+
message: 'Cannot list repository files: spawn git ENOENT.',
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('no runner at all is a sentence, not a throw', async () => {
|
|
158
|
+
assert.deepEqual(await listRepositoryFiles({ cwd: '/repo' }), {
|
|
159
|
+
ok: false,
|
|
160
|
+
message: 'Cannot list repository files: no Git runner was supplied.',
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// --- entries: state, recency and age --------------------------------------
|
|
165
|
+
|
|
166
|
+
test('changed files come first — untracked as new, dirty as updated, newest first — then the clean ones by path', async () => {
|
|
167
|
+
const root = tempDir();
|
|
168
|
+
const now = Date.parse('2024-05-01T12:00:00Z');
|
|
169
|
+
const dirty = writeFile(root, 'src/a.ts', 'export const a = 1;\n');
|
|
170
|
+
setMtime(dirty, now - 3 * HOUR);
|
|
171
|
+
const untracked = writeFile(root, 'notes.md', 'notes\n');
|
|
172
|
+
setMtime(untracked, now - 42_000);
|
|
173
|
+
writeFile(root, 'src/b.js', 'b\n');
|
|
174
|
+
writeFile(root, 'src/clean.ts', 'clean\n');
|
|
175
|
+
|
|
176
|
+
const { run, calls } = fakeRunner(gitAnswer({
|
|
177
|
+
listing: 'src/a.ts\0src/b.js\0notes.md\0src/clean.ts\0',
|
|
178
|
+
status: ' M src/a.ts\0?? notes.md\0',
|
|
179
|
+
root,
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
const result = await listRepositoryEntries({ run, cwd: '/repo', now });
|
|
183
|
+
|
|
184
|
+
assert.deepEqual(pairs(result.entries), [
|
|
185
|
+
['notes.md', 'new'],
|
|
186
|
+
['src/a.ts', 'updated'],
|
|
187
|
+
['src/b.js', 'clean'],
|
|
188
|
+
['src/clean.ts', 'clean'],
|
|
189
|
+
]);
|
|
190
|
+
assert.deepEqual(calls.map((call) => call.args), [LIST_ARGV, STATUS_ARGV, ROOT_ARGV],
|
|
191
|
+
'the three reads are the fixed argv, in that order');
|
|
192
|
+
assert.ok(calls.every((call) => call.opts.cwd === '/repo'), 'every read runs in the browsed checkout');
|
|
193
|
+
|
|
194
|
+
const newest = result.entries[0];
|
|
195
|
+
assert.equal(newest.mtimeMs, fs.statSync(untracked).mtimeMs, 'the mtime is a stat under the root Git reported');
|
|
196
|
+
assert.equal(newest.age, formatAge(fs.statSync(untracked).mtimeMs, now));
|
|
197
|
+
assert.match(newest.age, /^\d+s$/);
|
|
198
|
+
const older = result.entries[1];
|
|
199
|
+
assert.equal(older.mtimeMs, fs.statSync(dirty).mtimeMs);
|
|
200
|
+
assert.equal(older.age, formatAge(fs.statSync(dirty).mtimeMs, now));
|
|
201
|
+
assert.match(older.age, /^\d+h$/);
|
|
202
|
+
assert.deepEqual(result.entries[2], { path: 'src/b.js', state: 'clean' }, 'a clean row carries no time');
|
|
203
|
+
assert.deepEqual(result.entries[3], { path: 'src/clean.ts', state: 'clean' });
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test('the age is computed from the injected now, so the panel fixes it at open', async () => {
|
|
207
|
+
const root = tempDir();
|
|
208
|
+
const changed = writeFile(root, 'src/a.ts', 'x\n');
|
|
209
|
+
const mtimeMs = fs.statSync(changed).mtimeMs;
|
|
210
|
+
const plan = gitAnswer({ listing: 'src/a.ts\0', status: ' M src/a.ts\0', root });
|
|
211
|
+
|
|
212
|
+
const recent = await listRepositoryEntries({ run: fakeRunner(plan).run, cwd: '/repo', now: mtimeMs + 90_000 });
|
|
213
|
+
assert.equal(recent.entries[0].age, '1m');
|
|
214
|
+
|
|
215
|
+
const stale = await listRepositoryEntries({ run: fakeRunner(plan).run, cwd: '/repo', now: mtimeMs + 2 * DAY });
|
|
216
|
+
assert.equal(stale.entries[0].age, '2d');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
test('ties break by path, so the order is stable', async () => {
|
|
220
|
+
const root = tempDir();
|
|
221
|
+
const stamp = Date.now() - HOUR;
|
|
222
|
+
setMtime(writeFile(root, 'zeta.ts', 'z\n'), stamp);
|
|
223
|
+
setMtime(writeFile(root, 'alpha.ts', 'a\n'), stamp);
|
|
224
|
+
|
|
225
|
+
const { run } = fakeRunner(gitAnswer({
|
|
226
|
+
listing: 'zeta.ts\0alpha.ts\0',
|
|
227
|
+
status: '?? zeta.ts\0?? alpha.ts\0',
|
|
228
|
+
root,
|
|
229
|
+
}));
|
|
230
|
+
|
|
231
|
+
const result = await listRepositoryEntries({ run, cwd: '/repo', now: stamp });
|
|
232
|
+
assert.deepEqual(pairs(result.entries), [['alpha.ts', 'new'], ['zeta.ts', 'new']]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('an unreadable root or a file that is not on disk removes the age instead of the row', async () => {
|
|
236
|
+
const root = tempDir();
|
|
237
|
+
const present = writeFile(root, 'present.ts', 'p\n');
|
|
238
|
+
const { run } = fakeRunner(gitAnswer({
|
|
239
|
+
listing: 'present.ts\0gone.ts\0',
|
|
240
|
+
status: ' M present.ts\0 D gone.ts\0',
|
|
241
|
+
root,
|
|
242
|
+
}));
|
|
243
|
+
|
|
244
|
+
const result = await listRepositoryEntries({ run, cwd: '/repo', now: Date.now() });
|
|
245
|
+
|
|
246
|
+
assert.deepEqual(pairs(result.entries), [['present.ts', 'updated'], ['gone.ts', 'updated']],
|
|
247
|
+
'the timed change comes first, the untimed one after');
|
|
248
|
+
assert.equal(typeof result.entries[0].mtimeMs, 'number');
|
|
249
|
+
assert.deepEqual(result.entries[1], { path: 'gone.ts', state: 'updated' }, 'no timestamp, no age');
|
|
250
|
+
|
|
251
|
+
const noRoot = fakeRunner(gitAnswer({ listing: 'present.ts\0', status: ' M present.ts\0', root: undefined }));
|
|
252
|
+
const withoutRoot = await listRepositoryEntries({ run: noRoot.run, cwd: '/repo', now: Date.now() });
|
|
253
|
+
assert.deepEqual(pairs(withoutRoot.entries), [['present.ts', 'updated']], 'a failed rev-parse is not a failed listing');
|
|
254
|
+
assert.deepEqual(withoutRoot.entries[0], { path: 'present.ts', state: 'updated' });
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test('a rename record skips its original path field', async () => {
|
|
258
|
+
const { run } = fakeRunner(gitAnswer({
|
|
259
|
+
listing: 'src/new.ts\0src/old.ts\0',
|
|
260
|
+
status: 'R src/new.ts\0src/old.ts\0',
|
|
261
|
+
root: undefined,
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
const result = await listRepositoryEntries({ run, cwd: '/repo', now: Date.now() });
|
|
265
|
+
assert.deepEqual(pairs(result.entries), [['src/new.ts', 'updated'], ['src/old.ts', 'clean']],
|
|
266
|
+
'the original path is not a record of its own, so it is not marked changed');
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test('no changed file means the root is never resolved', async () => {
|
|
270
|
+
const { run, calls } = fakeRunner(gitAnswer({ listing: 'a.ts\0b.ts\0', status: '', root: undefined }));
|
|
271
|
+
|
|
272
|
+
const result = await listRepositoryEntries({ run, cwd: '/repo', now: Date.now() });
|
|
273
|
+
|
|
274
|
+
assert.deepEqual(pairs(result.entries), [['a.ts', 'clean'], ['b.ts', 'clean']]);
|
|
275
|
+
assert.deepEqual(calls.map((call) => call.args), [LIST_ARGV, STATUS_ARGV]);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('a failed status is a sentence, never a half listing', async () => {
|
|
279
|
+
// The listing succeeds and only the status read fails, so the sentence names
|
|
280
|
+
// the change read and no rows are painted from half the information.
|
|
281
|
+
const failingStatus = (stderr) => fakeRunner((args) => {
|
|
282
|
+
if (args[0] === 'ls-files') return { status: 0, stdout: 'a.ts\0', stderr: '' };
|
|
283
|
+
return { status: 128, stdout: '', stderr };
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const generic = failingStatus('fatal: index file smaller than expected');
|
|
287
|
+
assert.deepEqual(await listRepositoryEntries({ run: generic.run, cwd: '/repo', now: 0 }), {
|
|
288
|
+
ok: false,
|
|
289
|
+
message: 'Cannot read repository changes: fatal: index file smaller than expected.',
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const outside = failingStatus('fatal: not a git repository (or any of the parent directories): .git');
|
|
293
|
+
assert.deepEqual(await listRepositoryEntries({ run: outside.run, cwd: '/repo', now: 0 }), {
|
|
294
|
+
ok: false,
|
|
295
|
+
message: 'Not a Git repository: /repo.',
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test('every Git read is a fixed read-only argv: nothing stages, commits or checks out', async () => {
|
|
300
|
+
const root = tempDir();
|
|
301
|
+
const { run, calls } = fakeRunner(gitAnswer({
|
|
302
|
+
listing: 'src/a.ts\0',
|
|
303
|
+
status: ' M src/a.ts\0',
|
|
304
|
+
root,
|
|
305
|
+
}));
|
|
306
|
+
|
|
307
|
+
await listRepositoryEntries({ run, cwd: '/repo', now: Date.now() });
|
|
308
|
+
|
|
309
|
+
assert.equal(calls.length, 3);
|
|
310
|
+
for (const call of calls) {
|
|
311
|
+
assert.ok(Array.isArray(call.args) && call.args.every((entry) => typeof entry === 'string'), 'fixed argv, never a shell string');
|
|
312
|
+
const verb = call.args[0] === '--no-optional-locks' ? call.args[1] : call.args[0];
|
|
313
|
+
assert.ok(['ls-files', 'status', 'rev-parse'].includes(verb), `read-only read: ${verb}`);
|
|
314
|
+
}
|
|
315
|
+
assert.ok(calls[1].args.includes('--no-optional-locks'), 'status may not write the index back');
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
// --- formatAge -------------------------------------------------------------
|
|
319
|
+
|
|
320
|
+
test('formatAge labels one elapsed age in s, m, h and d', () => {
|
|
321
|
+
const now = 1_700_000_000_000;
|
|
322
|
+
assert.equal(formatAge(now, now), '0s');
|
|
323
|
+
assert.equal(formatAge(now - 5_000, now), '5s');
|
|
324
|
+
assert.equal(formatAge(now - 59_000, now), '59s');
|
|
325
|
+
assert.equal(formatAge(now - MINUTE, now), '1m');
|
|
326
|
+
assert.equal(formatAge(now - 59 * MINUTE, now), '59m');
|
|
327
|
+
assert.equal(formatAge(now - HOUR, now), '1h');
|
|
328
|
+
assert.equal(formatAge(now - 23 * HOUR, now), '23h');
|
|
329
|
+
assert.equal(formatAge(now - DAY, now), '1d');
|
|
330
|
+
assert.equal(formatAge(now - 30 * DAY, now), '30d');
|
|
331
|
+
assert.equal(formatAge(now + 5_000, now), '0s', 'a future mtime never paints a negative age');
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// --- the preview -----------------------------------------------------------
|
|
335
|
+
|
|
336
|
+
test('a text file previews its lines with no truncation', () => {
|
|
337
|
+
const root = tempDir();
|
|
338
|
+
writeFile(root, 'src/a.ts', 'one\ntwo\nthree\n');
|
|
339
|
+
|
|
340
|
+
assert.deepEqual(readFilePreview(root, 'src/a.ts'), {
|
|
341
|
+
kind: 'text',
|
|
342
|
+
lines: ['one', 'two', 'three'],
|
|
343
|
+
truncated: false,
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test('CRLF and a lone CR are line breaks, and a trailing newline is not a blank line', () => {
|
|
348
|
+
const root = tempDir();
|
|
349
|
+
writeFile(root, 'crlf.txt', 'a\r\nb\rc\nd');
|
|
350
|
+
assert.deepEqual(readFilePreview(root, 'crlf.txt').lines, ['a', 'b', 'c', 'd']);
|
|
351
|
+
|
|
352
|
+
writeFile(root, 'empty.txt', '');
|
|
353
|
+
assert.deepEqual(readFilePreview(root, 'empty.txt'), { kind: 'text', lines: [], truncated: false });
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test('the byte budget truncates explicitly, and a file of exactly the budget does not', () => {
|
|
357
|
+
const root = tempDir();
|
|
358
|
+
writeFile(root, 'exact.txt', 'abcdefghij');
|
|
359
|
+
assert.deepEqual(readFilePreview(root, 'exact.txt', { maxBytes: 10 }), {
|
|
360
|
+
kind: 'text',
|
|
361
|
+
lines: ['abcdefghij'],
|
|
362
|
+
truncated: false,
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
writeFile(root, 'over.txt', 'abcdefghijk');
|
|
366
|
+
assert.deepEqual(readFilePreview(root, 'over.txt', { maxBytes: 10 }), {
|
|
367
|
+
kind: 'text',
|
|
368
|
+
lines: ['abcdefghij'],
|
|
369
|
+
truncated: true,
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test('the line cap truncates explicitly and keeps whole lines', () => {
|
|
374
|
+
const root = tempDir();
|
|
375
|
+
writeFile(root, 'many.txt', 'l1\nl2\nl3\nl4\nl5\n');
|
|
376
|
+
|
|
377
|
+
assert.deepEqual(readFilePreview(root, 'many.txt', { maxLines: 3 }), {
|
|
378
|
+
kind: 'text',
|
|
379
|
+
lines: ['l1', 'l2', 'l3'],
|
|
380
|
+
truncated: true,
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
test('a line wider than the cap ends in the ellipsis mark', () => {
|
|
385
|
+
const root = tempDir();
|
|
386
|
+
writeFile(root, 'wide.txt', 'abcdefghij\n');
|
|
387
|
+
|
|
388
|
+
assert.deepEqual(readFilePreview(root, 'wide.txt', { maxLineWidth: 5 }), {
|
|
389
|
+
kind: 'text',
|
|
390
|
+
lines: ['abcd\u2026'],
|
|
391
|
+
truncated: true,
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
test('an override can only lower a bound, never lift it', () => {
|
|
396
|
+
const root = tempDir();
|
|
397
|
+
const longLine = 'x'.repeat(1_000);
|
|
398
|
+
writeFile(root, 'long.txt', `${longLine}\n`);
|
|
399
|
+
|
|
400
|
+
const raised = readFilePreview(root, 'long.txt', { maxLineWidth: 5_000 });
|
|
401
|
+
assert.equal(raised.kind, 'text');
|
|
402
|
+
assert.equal(raised.lines.length, 1);
|
|
403
|
+
assert.equal(raised.lines[0].length, FILE_PREVIEW_LIMITS.maxLineWidth, 'the default cap still applies');
|
|
404
|
+
assert.equal(raised.lines[0].endsWith('\u2026'), true);
|
|
405
|
+
assert.equal(raised.truncated, true);
|
|
406
|
+
|
|
407
|
+
const defaulted = readFilePreview(root, 'long.txt');
|
|
408
|
+
assert.deepEqual(defaulted, raised);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
test('a NUL byte is the binary notice, never bytes', () => {
|
|
412
|
+
const root = tempDir();
|
|
413
|
+
writeFile(root, 'image.png', Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x00, 0x01, 0x02]));
|
|
414
|
+
|
|
415
|
+
assert.deepEqual(readFilePreview(root, 'image.png'), { kind: 'binary', message: FILE_PREVIEW_BINARY_NOTICE });
|
|
416
|
+
assert.equal(FILE_PREVIEW_BINARY_NOTICE, 'Binary file \u2014 preview not available.');
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test('a missing file and a directory are error sentences with their code', () => {
|
|
420
|
+
const root = tempDir();
|
|
421
|
+
fs.mkdirSync(path.join(root, 'folder'));
|
|
422
|
+
|
|
423
|
+
const missing = readFilePreview(root, 'missing.ts');
|
|
424
|
+
assert.equal(missing.kind, 'error');
|
|
425
|
+
assert.equal(missing.message, 'Cannot read missing.ts (ENOENT).');
|
|
426
|
+
|
|
427
|
+
const directory = readFilePreview(root, 'folder');
|
|
428
|
+
assert.equal(directory.kind, 'error');
|
|
429
|
+
assert.match(directory.message, /^Cannot read folder \(E[A-Z]+\)\.$/);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test('a path climbing out of the checkout is refused instead of read', () => {
|
|
433
|
+
const root = tempDir();
|
|
434
|
+
const sibling = path.join(root, '..', `files-index-outside-${process.pid}.txt`);
|
|
435
|
+
writeFile(root, 'inside.txt', 'in\n');
|
|
436
|
+
|
|
437
|
+
const climbing = readFilePreview(root, '../inside.txt');
|
|
438
|
+
assert.equal(climbing.kind, 'error');
|
|
439
|
+
assert.equal(climbing.message, 'Cannot read ../inside.txt: outside the checkout.');
|
|
440
|
+
|
|
441
|
+
const absolute = readFilePreview(root, path.join(root, 'inside.txt'));
|
|
442
|
+
assert.equal(absolute.kind, 'error');
|
|
443
|
+
assert.match(absolute.message, /outside the checkout\.$/);
|
|
444
|
+
|
|
445
|
+
assert.equal(fs.existsSync(sibling), false, 'nothing was created outside the checkout');
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test('junk arguments never throw', () => {
|
|
449
|
+
const root = tempDir();
|
|
450
|
+
writeFile(root, 'a.txt', 'a\n');
|
|
451
|
+
|
|
452
|
+
for (const [where, which, opts] of [
|
|
453
|
+
[undefined, undefined, undefined],
|
|
454
|
+
[null, null, {}],
|
|
455
|
+
[root, 42, {}],
|
|
456
|
+
[root, '', {}],
|
|
457
|
+
['', 'a.txt', {}],
|
|
458
|
+
[root, 'a.txt', 42],
|
|
459
|
+
[root, undefined, { maxBytes: 'nonsense', maxLines: -1 }],
|
|
460
|
+
]) {
|
|
461
|
+
const preview = readFilePreview(where, which, opts);
|
|
462
|
+
assert.ok(['text', 'error'].includes(preview.kind), `junk arguments answer a preview: ${JSON.stringify(preview)}`);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
assert.deepEqual(readFilePreview(root, 'a.txt', 42), { kind: 'text', lines: ['a'], truncated: false },
|
|
466
|
+
'junk options fall back to the shipped limits');
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
test('the shipped limits are the bounded constants the view paints against', () => {
|
|
470
|
+
assert.deepEqual({ ...FILE_PREVIEW_LIMITS }, { maxBytes: 64 * 1024, maxLines: 200, maxLineWidth: 400 });
|
|
471
|
+
assert.equal(Object.isFrozen(FILE_PREVIEW_LIMITS), true, 'a caller cannot widen the bounds by mutating the table');
|
|
472
|
+
assert.equal(typeof FILE_PREVIEW_BINARY_NOTICE, 'string');
|
|
473
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// S8: the picker's insertion form. A file below the session cwd is `@` plus its
|
|
3
|
+
// path from that cwd, because Pi resolves `@` against the session cwd; any other
|
|
4
|
+
// file is its real absolute path, never a `~` form. The rules are asserted
|
|
5
|
+
// through the module's public surface only.
|
|
6
|
+
|
|
7
|
+
const { test, describe } = require('node:test');
|
|
8
|
+
const assert = require('node:assert/strict');
|
|
9
|
+
|
|
10
|
+
const { fileReference, formatFileInsertion } = require('../lib/files-insert.js');
|
|
11
|
+
|
|
12
|
+
const MAIN = { root: '/repo', kind: 'main', cwd: '/repo' };
|
|
13
|
+
const WORKTREE = { root: '/home/dev/odd-worktrees/feature', kind: 'worktree', cwd: '/repo' };
|
|
14
|
+
|
|
15
|
+
// A session started in a subdirectory: the repository root is still /repo,
|
|
16
|
+
// but Pi resolves `@` against /repo/packages/app.
|
|
17
|
+
const SUBDIRECTORY = { root: '/repo', kind: 'main', cwd: '/repo/packages/app' };
|
|
18
|
+
|
|
19
|
+
describe('the file picker inserts the chosen files as references (S8)', () => {
|
|
20
|
+
test('a file from the session repository is inserted as @ plus its relative path', () => {
|
|
21
|
+
assert.equal(formatFileInsertion(['AGENTS.md'], MAIN), '@AGENTS.md');
|
|
22
|
+
assert.equal(formatFileInsertion(['src/index.js'], MAIN), '@src/index.js');
|
|
23
|
+
assert.equal(formatFileInsertion(['lib/view-layout.js'], MAIN), '@lib/view-layout.js');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('a file from another checkout is inserted as its absolute path, never @', () => {
|
|
27
|
+
assert.equal(
|
|
28
|
+
formatFileInsertion(['src/index.js'], WORKTREE),
|
|
29
|
+
'/home/dev/odd-worktrees/feature/src/index.js'
|
|
30
|
+
);
|
|
31
|
+
assert.equal(formatFileInsertion(['AGENTS.md'], WORKTREE).startsWith('@'), false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('nested relative paths keep every separator', () => {
|
|
35
|
+
assert.equal(
|
|
36
|
+
formatFileInsertion(['packages/app/src/deep/file.js'], MAIN),
|
|
37
|
+
'@packages/app/src/deep/file.js'
|
|
38
|
+
);
|
|
39
|
+
assert.equal(
|
|
40
|
+
formatFileInsertion(['packages/app/src/deep/file.js'], WORKTREE),
|
|
41
|
+
'/home/dev/odd-worktrees/feature/packages/app/src/deep/file.js'
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('several files join with one space, in the given order', () => {
|
|
46
|
+
assert.equal(formatFileInsertion(['b.js', 'a.js', 'dir/c.js'], MAIN), '@b.js @a.js @dir/c.js');
|
|
47
|
+
assert.equal(
|
|
48
|
+
formatFileInsertion(['one.js', 'two.js'], WORKTREE),
|
|
49
|
+
'/home/dev/odd-worktrees/feature/one.js /home/dev/odd-worktrees/feature/two.js'
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('the joined text has no leading, trailing or doubled separator', () => {
|
|
54
|
+
const text = formatFileInsertion(['one.js', 'two.js', 'three.js'], MAIN);
|
|
55
|
+
assert.equal(text, text.trim());
|
|
56
|
+
assert.equal(/ {2}/.test(text), false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('an empty list yields an empty string', () => {
|
|
60
|
+
assert.equal(formatFileInsertion([], MAIN), '');
|
|
61
|
+
assert.equal(formatFileInsertion([], WORKTREE), '');
|
|
62
|
+
assert.equal(fileReference(MAIN, ''), '');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a path is never duplicated by the formatter', () => {
|
|
66
|
+
const absolute = '/home/dev/odd-worktrees/feature/src/index.js';
|
|
67
|
+
assert.equal(formatFileInsertion([absolute], WORKTREE), absolute);
|
|
68
|
+
assert.equal(formatFileInsertion(['src/index.js'], WORKTREE), absolute);
|
|
69
|
+
assert.equal(formatFileInsertion(['src/index.js', 'src/index.js'], WORKTREE), absolute);
|
|
70
|
+
assert.equal(formatFileInsertion(['src/index.js', 'src/index.js'], MAIN), '@src/index.js');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('Windows-style separators normalise to forward slashes', () => {
|
|
74
|
+
assert.equal(formatFileInsertion(['src\\index.js'], MAIN), '@src/index.js');
|
|
75
|
+
assert.equal(formatFileInsertion(['src\\nested\\dir\\file.js'], MAIN), '@src/nested/dir/file.js');
|
|
76
|
+
assert.equal(
|
|
77
|
+
formatFileInsertion(['src\\index.js'], { root: 'C:\\repo\\wt', kind: 'worktree', cwd: 'C:/repo' }),
|
|
78
|
+
'C:/repo/wt/src/index.js'
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('the home directory is never abbreviated to ~', () => {
|
|
83
|
+
const text = formatFileInsertion(['src/index.js'], {
|
|
84
|
+
root: '/home/dev/odd-worktrees/feature',
|
|
85
|
+
kind: 'worktree',
|
|
86
|
+
cwd: '/repo',
|
|
87
|
+
});
|
|
88
|
+
assert.equal(text.includes('~'), false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('a file below the session cwd is @ plus the path from that cwd, not from the repository root', () => {
|
|
92
|
+
assert.equal(formatFileInsertion(['packages/app/src/index.js'], SUBDIRECTORY), '@src/index.js');
|
|
93
|
+
assert.equal(formatFileInsertion(['packages/app/AGENTS.md'], SUBDIRECTORY), '@AGENTS.md');
|
|
94
|
+
assert.equal(
|
|
95
|
+
formatFileInsertion(['packages/app/src/index.js'], { ...SUBDIRECTORY, cwd: '/repo/packages/app/' }),
|
|
96
|
+
'@src/index.js',
|
|
97
|
+
'a trailing slash on the cwd changes nothing'
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('a repository file outside the session cwd is inserted as its real absolute path', () => {
|
|
102
|
+
assert.equal(
|
|
103
|
+
formatFileInsertion(['lib/view-layout.js'], SUBDIRECTORY),
|
|
104
|
+
'/repo/lib/view-layout.js',
|
|
105
|
+
'a file above the cwd cannot be named relative to it'
|
|
106
|
+
);
|
|
107
|
+
assert.equal(
|
|
108
|
+
formatFileInsertion(['packages/other/x.js'], SUBDIRECTORY),
|
|
109
|
+
'/repo/packages/other/x.js',
|
|
110
|
+
'a sibling directory is outside the cwd'
|
|
111
|
+
);
|
|
112
|
+
assert.equal(
|
|
113
|
+
formatFileInsertion(['packages/app/src/index.js', 'lib/view-layout.js'], SUBDIRECTORY),
|
|
114
|
+
'@src/index.js /repo/lib/view-layout.js',
|
|
115
|
+
'each file is named from the cwd that holds it'
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('a path that begins with ~ is emitted as its real absolute path, never in ~ form', () => {
|
|
120
|
+
assert.equal(formatFileInsertion(['~/notes.md'], MAIN), '/repo/~/notes.md');
|
|
121
|
+
assert.equal(formatFileInsertion(['~'], MAIN), '/repo/~');
|
|
122
|
+
assert.equal(formatFileInsertion(['~/notes.md'], MAIN).startsWith('~'), false);
|
|
123
|
+
const underHome = { root: '/home/dev/repo', kind: 'main', cwd: '/home/dev/repo' };
|
|
124
|
+
assert.equal(formatFileInsertion(['src/index.js'], underHome), '@src/index.js');
|
|
125
|
+
assert.equal(formatFileInsertion(['src/index.js'], underHome).startsWith('~'), false);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('another checkout stays absolute even when the session cwd is that checkout', () => {
|
|
129
|
+
const inWorktree = {
|
|
130
|
+
root: '/home/dev/odd-worktrees/feature',
|
|
131
|
+
kind: 'worktree',
|
|
132
|
+
cwd: '/home/dev/odd-worktrees/feature',
|
|
133
|
+
};
|
|
134
|
+
assert.equal(
|
|
135
|
+
formatFileInsertion(['src/index.js'], inWorktree),
|
|
136
|
+
'/home/dev/odd-worktrees/feature/src/index.js'
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
});
|