pi-odd-worktree 2.1.0 → 3.0.1
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 -319
- package/extensions/odd-worktree-tools.ts +4182 -2539
- package/lib/bash-activity.js +1166 -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 +1421 -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 +323 -15
- 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 -712
- 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 +1420 -0
- package/tools/bash-design.test.js +1093 -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 +613 -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 +1889 -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 +417 -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 +1517 -67
- package/tools/issues-open-guard.test.js +1096 -0
- package/tools/issues-section.test.js +4235 -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 +2565 -309
- 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 +419 -199
- 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
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// The create
|
|
3
|
-
// from the two fields the form asks for.
|
|
2
|
+
// The create wizard: `Branch · Odd` (warp-branch-field S1,S2,S6,S7,S8,S9,S10).
|
|
4
3
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
4
|
+
// `Branch` is the human's branch — `<type>/<name>`, the type chosen from the
|
|
5
|
+
// repository's eleven types and the name typed — and the ODD is the checkout's
|
|
6
|
+
// directory, chosen from the ODDs that exist in `main` (first entry `new odd`,
|
|
7
|
+
// the only typed case). There is no `Name` field: the checkout's directory IS
|
|
8
|
+
// the ODD, and the branch names no directory. Both typed fields share ONE input
|
|
9
|
+
// design, the lists beside them stay plain rows, and a blank separator keeps the
|
|
10
|
+
// input region apart from its list.
|
|
11
|
+
//
|
|
12
|
+
// S5: an ODD whose checkout already exists is not offered, from the reconciled
|
|
13
|
+
// live checkouts the caller supplies; `new odd` stays first and available, and
|
|
14
|
+
// an empty result is never an error.
|
|
15
|
+
//
|
|
16
|
+
// Nothing here writes a file: the wizard creates nothing, an escape writes
|
|
17
|
+
// nothing, and the document of an ODD is left to the agent.
|
|
12
18
|
//
|
|
13
19
|
// Every test renders headlessly against a real temporary repository (the path
|
|
14
20
|
// derivation reads the real repository identity through the same helpers the
|
|
15
|
-
// create path uses) and asserts each line is exactly the requested width.
|
|
16
|
-
//
|
|
21
|
+
// create path uses) and asserts each line is exactly the requested width. The
|
|
22
|
+
// temporary repository is removed when the suite ends.
|
|
17
23
|
|
|
18
24
|
const { test, describe, after } = require('node:test');
|
|
19
25
|
const assert = require('node:assert/strict');
|
|
@@ -24,6 +30,7 @@ const { execFileSync } = require('node:child_process');
|
|
|
24
30
|
|
|
25
31
|
const panel = require('../lib/warp-create-panel.js');
|
|
26
32
|
const realGit = require('../lib/worktree-git.js');
|
|
33
|
+
const createLib = require('../lib/worktree-create.js');
|
|
27
34
|
|
|
28
35
|
const scratch = [];
|
|
29
36
|
after(() => {
|
|
@@ -61,6 +68,11 @@ function renderedLines(view, width = 120) {
|
|
|
61
68
|
return lines;
|
|
62
69
|
}
|
|
63
70
|
|
|
71
|
+
// The trimmed plain text of every row, which is what a human sees.
|
|
72
|
+
function rows(view, width = 120) {
|
|
73
|
+
return renderedLines(view, width).map((line) => stripAnsi(line).trimEnd());
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
function findLine(lines, needle) {
|
|
65
77
|
const line = lines.find((entry) => stripAnsi(entry).includes(needle));
|
|
66
78
|
assert.ok(line !== undefined, `no line contains ${JSON.stringify(needle)}\n${lines.map(stripAnsi).join('\n')}`);
|
|
@@ -77,6 +89,10 @@ function previewText(view, which) {
|
|
|
77
89
|
return findLine(renderedLines(view), `preview ${which}:`).replace(`preview ${which}: `, '').trimEnd();
|
|
78
90
|
}
|
|
79
91
|
|
|
92
|
+
function rowIndex(lines, needle) {
|
|
93
|
+
return lines.findIndex((line) => line.includes(needle));
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
function openPanel(overrides = {}) {
|
|
81
97
|
const finished = [];
|
|
82
98
|
const view = panel.createWarpCreatePanel({
|
|
@@ -85,101 +101,510 @@ function openPanel(overrides = {}) {
|
|
|
85
101
|
helpers: null,
|
|
86
102
|
hostTui: null,
|
|
87
103
|
theme: null,
|
|
88
|
-
rowsAvailable: () =>
|
|
104
|
+
rowsAvailable: () => 30,
|
|
89
105
|
done: (value) => { finished.push(value); },
|
|
90
106
|
...overrides,
|
|
91
107
|
});
|
|
92
108
|
return { view, finished };
|
|
93
109
|
}
|
|
94
110
|
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
// The strip holds TWO fields, so a helper steps to the one it wants from
|
|
112
|
+
// wherever the panel is instead of assuming a starting tab.
|
|
113
|
+
function focusField(view, field) {
|
|
114
|
+
for (let step = 0; step < 4 && view.state.focus !== field; step += 1) view.handleInput('\t');
|
|
115
|
+
assert.equal(view.state.focus, field, `the panel never reached the ${field} field`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function focusOdd(view) {
|
|
119
|
+
focusField(view, 'odd');
|
|
97
120
|
}
|
|
98
121
|
|
|
99
122
|
function typeText(view, text) {
|
|
100
123
|
for (const char of text) view.handleInput(char);
|
|
101
124
|
}
|
|
102
125
|
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
// The ODD is the LAST field, so submitting is one `enter` there.
|
|
127
|
+
function submit(view) {
|
|
128
|
+
focusOdd(view);
|
|
105
129
|
view.handleInput('enter');
|
|
106
130
|
}
|
|
107
131
|
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
// A whole-tree snapshot (relative path -> size), so "writes nothing" is proven
|
|
133
|
+
// against the filesystem and not against a claim.
|
|
134
|
+
function treeSnapshot(root) {
|
|
135
|
+
const rowsOut = [];
|
|
136
|
+
const walk = (dir, prefix) => {
|
|
137
|
+
let names = [];
|
|
138
|
+
try { names = fs.readdirSync(dir).sort(); } catch { return; }
|
|
139
|
+
for (const name of names) {
|
|
140
|
+
const full = path.join(dir, name);
|
|
141
|
+
let stats;
|
|
142
|
+
try { stats = fs.lstatSync(full); } catch { continue; }
|
|
143
|
+
rowsOut.push(`${prefix}${name}:${stats.size}`);
|
|
144
|
+
if (stats.isDirectory() && name !== '.git') walk(full, `${prefix}${name}/`);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
walk(root, '');
|
|
148
|
+
return rowsOut;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
describe('the create wizard asks for the branch and the odd', { concurrency: false }, () => {
|
|
152
|
+
test('the strip is Branch · Odd: there is no Name field anywhere', () => {
|
|
153
|
+
const { view } = openPanel({ oddOptions: ['login-ui'] });
|
|
154
|
+
const text = allText(renderedLines(view));
|
|
155
|
+
assert.match(text, /Branch · Odd/, 'the strip names the two fields');
|
|
156
|
+
assert.ok(!/Type · Odd/.test(text), `the retired strip is not rendered\n${text}`);
|
|
157
|
+
assert.ok(!/\bName\b/.test(text), `no field or row is called Name\n${text}`);
|
|
158
|
+
assert.ok(!/Name:/.test(text), 'no Name row renders');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('the fields are tabs: tab and the arrows walk Branch → Odd and wrap', () => {
|
|
110
162
|
const { view } = openPanel();
|
|
111
|
-
assert.equal(
|
|
112
|
-
|
|
163
|
+
assert.equal(view.state.focus, 'branch', 'Branch is the first field');
|
|
164
|
+
view.handleInput('\t');
|
|
165
|
+
assert.equal(view.state.focus, 'odd', 'tab moves forward');
|
|
166
|
+
view.handleInput('\t');
|
|
167
|
+
assert.equal(view.state.focus, 'branch', 'the end wraps to the first field');
|
|
168
|
+
view.handleInput('\x1b[Z');
|
|
169
|
+
assert.equal(view.state.focus, 'odd', 'shift+tab moves back, wrapping at the first field');
|
|
170
|
+
view.handleInput('\x1b[D');
|
|
171
|
+
assert.equal(view.state.focus, 'branch', 'left moves back too');
|
|
172
|
+
view.handleInput('\x1b[C');
|
|
173
|
+
assert.equal(view.state.focus, 'odd', 'and right moves forward');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('enter on the branch reaches the ODD instead of creating', () => {
|
|
177
|
+
const { view, finished } = openPanel();
|
|
178
|
+
view.handleInput('enter');
|
|
179
|
+
assert.equal(view.state.focus, 'odd', 'the branch is no longer the last field');
|
|
180
|
+
assert.deepEqual(finished, [], 'nothing is created while the ODD is unanswered');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('the ODD list is main’s documents, sorted, with new odd first', () => {
|
|
184
|
+
const { view } = openPanel({ oddOptions: ['worktree-tools-v2', 'login-ui', 'login-ui'] });
|
|
185
|
+
focusOdd(view);
|
|
113
186
|
const text = allText(renderedLines(view));
|
|
114
|
-
|
|
115
|
-
assert.ok(
|
|
187
|
+
const at = (needle) => text.indexOf(needle);
|
|
188
|
+
assert.ok(at('❯ new odd') >= 0, `the first entry is the new-ODD entry\n${text}`);
|
|
189
|
+
assert.ok(at('❯ new odd') < at(' login-ui'), 'new odd comes before every document');
|
|
190
|
+
assert.ok(at(' login-ui') < at(' worktree-tools-v2'), 'the documents are sorted');
|
|
191
|
+
assert.equal(text.split('login-ui').length - 1, 1, 'a duplicate option is listed once');
|
|
116
192
|
});
|
|
117
193
|
|
|
118
|
-
test('
|
|
194
|
+
test('an absent list still offers new odd: an unreadable odd/tasks is never an error', () => {
|
|
195
|
+
const { view, finished } = openPanel();
|
|
196
|
+
focusOdd(view);
|
|
197
|
+
const text = allText(renderedLines(view));
|
|
198
|
+
assert.match(text, /❯ new odd/);
|
|
199
|
+
assert.ok(!text.includes('cannot'), `an empty list is not a failure\n${text}`);
|
|
200
|
+
typeText(view, 'login-ui');
|
|
201
|
+
view.handleInput('enter');
|
|
202
|
+
assert.deepEqual(finished, [], 'the branch name is still unanswered');
|
|
203
|
+
focusField(view, 'branch');
|
|
204
|
+
typeText(view, 'sign-in');
|
|
205
|
+
focusOdd(view);
|
|
206
|
+
view.handleInput('enter');
|
|
207
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/sign-in', odd: 'login-ui' }], 'a new ODD is still enterable');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('each fact is shown once: no second Odd: echo and no Name: row', () => {
|
|
211
|
+
const { view } = openPanel({ oddOptions: ['dagea'], initialOdd: 'dagea' });
|
|
212
|
+
focusOdd(view);
|
|
213
|
+
const lines = rows(view);
|
|
214
|
+
assert.ok(lines.includes('❯ dagea'), 'the picked document is the list row');
|
|
215
|
+
assert.equal(lines.filter((line) => /^Odd:/.test(line)).length, 0, `no stray Odd: row renders\n${lines.join('\n')}`);
|
|
216
|
+
assert.equal(lines.filter((line) => /^Name:/.test(line)).length, 0, 'no stray Name: row renders');
|
|
217
|
+
|
|
218
|
+
// And the same while the new-ODD entry is the one being typed into: the typed
|
|
219
|
+
// value lives IN that row, and the previews are the only other places that
|
|
220
|
+
// mention it.
|
|
221
|
+
const typed = openPanel();
|
|
222
|
+
focusOdd(typed.view);
|
|
223
|
+
typeText(typed.view, 'dagea');
|
|
224
|
+
const typedLines = rows(typed.view);
|
|
225
|
+
assert.equal(typedLines.filter((line) => line.includes('new odd:')).length, 1, 'the typed ODD renders in its own one row');
|
|
226
|
+
assert.equal(typedLines.filter((line) => /dagea/.test(line)).length, 2, 'the row and the path preview name it, nothing else');
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('the Branch field: name on top, the types under it (S1,S6)', { concurrency: false }, () => {
|
|
231
|
+
test('an untouched form previews feat/ and reads the name above the list', () => {
|
|
232
|
+
const { view } = openPanel();
|
|
233
|
+
assert.equal(previewText(view, 'branch'), 'feat/', 'feat is the default type, so the form already previews it');
|
|
234
|
+
assert.equal(previewText(view, 'path'), WORKTREE_ROOT, 'the path preview names the root the ODD will complete into');
|
|
235
|
+
const lines = rows(view);
|
|
236
|
+
const input = rowIndex(lines, 'branch-name');
|
|
237
|
+
const firstType = rowIndex(lines, 'Feature (feat)');
|
|
238
|
+
assert.ok(input > 0 && firstType > 0, `both regions render\n${lines.join('\n')}`);
|
|
239
|
+
assert.ok(input < firstType, `the typed name sits ABOVE the type list\n${lines.join('\n')}`);
|
|
240
|
+
assert.equal(lines[input].trim(), '❯ feat/▊branch-name', 'the input composes the type prefix and the caret');
|
|
241
|
+
assert.equal(lines[input + 1].trim(), '', 'a blank row separates the input region from the list (S7)');
|
|
242
|
+
assert.ok(firstType > input + 1, 'the list starts after the separator');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('choosing a type moves the composed branch and never the directory', () => {
|
|
246
|
+
const { view } = openPanel({ oddOptions: ['login-ui'] });
|
|
247
|
+
focusOdd(view);
|
|
248
|
+
view.handleInput('\x1b[B'); // down: login-ui
|
|
249
|
+
focusField(view, 'branch');
|
|
250
|
+
view.handleInput('\x1b[B'); // down: Bug fix
|
|
251
|
+
assert.equal(previewText(view, 'branch'), 'fix/', 'the composed branch follows the type');
|
|
252
|
+
assert.equal(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'login-ui'), 'the type never names the directory');
|
|
253
|
+
assert.equal(rows(view)[rowIndex(rows(view), 'branch-name')].trim(), '❯ fix/▊branch-name', 'the input row shows the chosen prefix');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test('typing fills the name in place and the preview composes <type>/<name>', () => {
|
|
257
|
+
const { view } = openPanel({ oddOptions: ['login-ui'] });
|
|
258
|
+
typeText(view, 'add');
|
|
259
|
+
assert.equal(view.state.focus, 'branch', 'typing never jumps fields');
|
|
260
|
+
assert.equal(previewText(view, 'branch'), 'feat/add');
|
|
261
|
+
assert.equal(rows(view)[rowIndex(rows(view), '▊')].trim(), '❯ feat/add▊', 'the typed text lives in the input row');
|
|
262
|
+
view.handleInput('\x7f');
|
|
263
|
+
assert.equal(previewText(view, 'branch'), 'feat/ad', 'backspace edits the name');
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test('every change type previews its own branch, and the list keeps its eleven entries', () => {
|
|
267
|
+
assert.equal(panel.CHANGE_TYPES.length, 11, 'the eleven types survive');
|
|
268
|
+
const expected = ['feat', 'fix', 'chore', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'revert'];
|
|
269
|
+
assert.deepEqual(panel.CHANGE_TYPES.map((type) => type.id), expected, 'in the branch-pr order');
|
|
119
270
|
for (const type of panel.CHANGE_TYPES) {
|
|
120
271
|
const { view } = openPanel({ initialType: type.id });
|
|
121
|
-
|
|
122
|
-
assert.equal(previewText(view, '
|
|
272
|
+
typeText(view, 'x');
|
|
273
|
+
assert.equal(previewText(view, 'branch'), `${type.id}/x`, `${type.id} composes its own branch`);
|
|
274
|
+
// The list keeps every type, in order, as plain rows.
|
|
275
|
+
const lines = rows(view);
|
|
276
|
+
const rendered = panel.CHANGE_TYPES.map((entry) => `${entry.label} (${entry.id})`);
|
|
277
|
+
const at = rendered.map((label) => rowIndex(lines, label));
|
|
278
|
+
assert.ok(at.every((index) => index > 0), `${type.id}: every type renders\n${lines.join('\n')}`);
|
|
279
|
+
assert.deepEqual([...at].sort((a, b) => a - b), at, `${type.id}: the list keeps its order`);
|
|
123
280
|
}
|
|
124
281
|
});
|
|
125
282
|
|
|
126
|
-
test('
|
|
283
|
+
test('the branch is passed through unchanged and the path follows the ODD alone', () => {
|
|
284
|
+
const { view, finished } = openPanel({ oddOptions: ['dagea'] });
|
|
285
|
+
typeText(view, 'other-name');
|
|
286
|
+
focusOdd(view);
|
|
287
|
+
view.handleInput('\x1b[B'); // down: dagea
|
|
288
|
+
assert.equal(previewText(view, 'branch'), 'feat/other-name', 'the branch is the typed pair, not the ODD');
|
|
289
|
+
assert.equal(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'dagea'), 'the ODD names the directory');
|
|
290
|
+
view.handleInput('enter');
|
|
291
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/other-name', odd: 'dagea' }], 'the completion carries the branch verbatim');
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('a name that is not a branch segment refuses with its own words', () => {
|
|
295
|
+
const { view, finished } = openPanel();
|
|
296
|
+
// The space is not what refuses this name: it collapses to one dash like
|
|
297
|
+
// every other space run, and the UPPERCASE is the surviving reason.
|
|
298
|
+
typeText(view, 'Bad Name');
|
|
299
|
+
assert.equal(previewText(view, 'branch'), '-', 'an invalid branch previews no branch');
|
|
300
|
+
assert.equal(previewText(view, 'path'), WORKTREE_ROOT, 'the path row stays neutral, not blank');
|
|
301
|
+
submit(view);
|
|
302
|
+
assert.deepEqual(finished, [], 'an invalid branch creates nothing');
|
|
303
|
+
assert.match(allText(renderedLines(view)), /cannot create: invalid branch name: feat\/Bad-Name/);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe('both typed fields share one input design (S7,S8,S9,S10)', { concurrency: false }, () => {
|
|
308
|
+
test('the branch name and new odd render as the same kind of row', () => {
|
|
309
|
+
const branch = openPanel();
|
|
310
|
+
const branchInput = rows(branch.view).find((line) => line.includes('branch-name'));
|
|
311
|
+
assert.equal(branchInput.trim(), '❯ feat/▊branch-name');
|
|
312
|
+
|
|
313
|
+
const odd = openPanel();
|
|
314
|
+
focusOdd(odd.view);
|
|
315
|
+
const oddInput = rows(odd.view).find((line) => line.includes('odd-name'));
|
|
316
|
+
assert.equal(oddInput.trim(), '❯ new odd: ▊odd-name');
|
|
317
|
+
|
|
318
|
+
// The shape both share: the `❯` prompt, a static label or the composed
|
|
319
|
+
// prefix, then the caret — the same row treatment, never a second style.
|
|
320
|
+
for (const input of [branchInput.trim(), oddInput.trim()]) {
|
|
321
|
+
assert.match(input, /^❯ /, 'the prompt is the same');
|
|
322
|
+
assert.ok(input.includes('▊'), 'the caret is the same');
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
test('the new-odd row IS the input while it is selected, and the caret moves with it', () => {
|
|
327
|
+
const { view } = openPanel({ oddOptions: ['dagea', 'login-ui'] });
|
|
328
|
+
focusOdd(view);
|
|
329
|
+
const lines = rows(view);
|
|
330
|
+
// `new odd` selected: the row above the separator is the input, typed text in place.
|
|
331
|
+
typeText(view, 'fresh');
|
|
332
|
+
const input = rowIndex(rows(view), 'new odd:');
|
|
333
|
+
assert.ok(input > 0);
|
|
334
|
+
assert.equal(rows(view)[input].trim(), '❯ new odd: fresh▊');
|
|
335
|
+
assert.equal(rows(view)[input + 1].trim(), '', 'the blank separator follows the input row');
|
|
336
|
+
assert.ok(rowIndex(rows(view), ' dagea') > input + 1, 'the documents stand alone under it, as plain rows');
|
|
337
|
+
assert.ok(!lines.some((line) => /^\s{2}dagea▊/.test(line)), 'no document row wears the caret');
|
|
338
|
+
|
|
339
|
+
// A document selected: no input row below the list, `new odd` stays plain.
|
|
340
|
+
view.handleInput('\x1b[B'); // down: dagea
|
|
341
|
+
const document = rows(view);
|
|
342
|
+
assert.equal(document.filter((line) => line.includes('▊')).length, 0, `no input row is left under the list\n${document.join('\n')}`);
|
|
343
|
+
assert.ok(document.includes(' new odd'), 'the new-odd entry stays (plain) in its place');
|
|
344
|
+
assert.ok(document.includes('❯ dagea'), 'the documents below are the list, and the focused one is marked');
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test('the lists are plain rows: neither list wears the input design', () => {
|
|
348
|
+
const branch = openPanel();
|
|
349
|
+
const branchLines = rows(branch.view);
|
|
350
|
+
const typeRows = branchLines.filter((line) => /^\s*(❯ )?(Feature|Bug fix|Chore) \(/.test(line));
|
|
351
|
+
assert.equal(typeRows.length, 3, 'the type list renders as plain rows');
|
|
352
|
+
for (const line of typeRows) assert.ok(!line.includes('▊'), 'no type row wears the caret');
|
|
353
|
+
|
|
354
|
+
const odd = openPanel({ oddOptions: ['dagea'] });
|
|
355
|
+
focusOdd(odd.view);
|
|
356
|
+
odd.view.handleInput('\x1b[B'); // down: dagea
|
|
357
|
+
for (const line of rows(odd.view).filter((text) => /dagea$/.test(text) && text.includes('❯'))) {
|
|
358
|
+
assert.ok(!line.includes('▊'), 'no document row is styled as an input');
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Both typed fields apply ONE rule before anything is composed: one or more
|
|
364
|
+
// consecutive spaces become a single `-`, so `change cost` is the ODD (or the
|
|
365
|
+
// branch name) `change-cost`. The rule sits AFTER the trim and BEFORE the
|
|
366
|
+
// composition, so leading and trailing spaces still vanish instead of becoming
|
|
367
|
+
// dashes, every other character keeps its existing rule, and a name that
|
|
368
|
+
// normalizes to nothing still refuses with its own words. The preview, the input
|
|
369
|
+
// row and the submitted value are the SAME derivation, never three spellings.
|
|
370
|
+
describe('both typed names collapse a run of spaces into one dash', { concurrency: false }, () => {
|
|
371
|
+
test('change cost previews feat/change-cost', () => {
|
|
127
372
|
const { view } = openPanel();
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
assert.equal(
|
|
131
|
-
assert.equal(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'feat-my'), 'the path preview follows them too');
|
|
132
|
-
typeText(view, '-name');
|
|
133
|
-
assert.equal(previewText(view, 'branch'), 'feat/my-name');
|
|
134
|
-
assert.equal(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'feat-my-name'));
|
|
373
|
+
typeText(view, 'change cost');
|
|
374
|
+
assert.equal(previewText(view, 'branch'), 'feat/change-cost', 'a run of spaces is one dash');
|
|
375
|
+
assert.equal(rows(view)[rowIndex(rows(view), '▊')].trim(), '❯ feat/change-cost▊', 'the input row shows the normalized name too');
|
|
135
376
|
});
|
|
136
377
|
|
|
137
|
-
test('
|
|
378
|
+
test('several spaces collapse to one dash, and a single space becomes one too', () => {
|
|
379
|
+
const many = openPanel();
|
|
380
|
+
typeText(many.view, 'a b c');
|
|
381
|
+
assert.equal(previewText(many.view, 'branch'), 'feat/a-b-c', 'each run is exactly one dash');
|
|
382
|
+
assert.ok(!previewText(many.view, 'branch').includes('--'), 'no run is expanded into several dashes');
|
|
383
|
+
|
|
384
|
+
const one = openPanel();
|
|
385
|
+
typeText(one.view, 'change cost');
|
|
386
|
+
assert.equal(previewText(one.view, 'branch'), 'feat/change-cost', 'a single space is one dash as well');
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
test('the submitted branch is exactly the previewed branch', () => {
|
|
390
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui'] });
|
|
391
|
+
typeText(view, 'change cost');
|
|
392
|
+
focusOdd(view);
|
|
393
|
+
view.handleInput('\x1b[B'); // down: login-ui
|
|
394
|
+
const preview = previewText(view, 'branch');
|
|
395
|
+
view.handleInput('enter');
|
|
396
|
+
assert.deepEqual(finished, [{ ok: true, branch: preview, odd: 'login-ui' }], 'the create makes what the preview showed');
|
|
397
|
+
assert.equal(finished[0].branch, 'feat/change-cost');
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test('the same rule holds in the ODD field, naming the path and the directory', () => {
|
|
138
401
|
const { view, finished } = openPanel();
|
|
139
|
-
|
|
140
|
-
view
|
|
141
|
-
|
|
142
|
-
assert.equal(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
assert.equal(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
view
|
|
152
|
-
|
|
153
|
-
assert.equal(previewText(view, '
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
402
|
+
typeText(view, 'sign-in');
|
|
403
|
+
focusOdd(view);
|
|
404
|
+
typeText(view, 'change cost');
|
|
405
|
+
assert.equal(rows(view)[rowIndex(rows(view), '▊')].trim(), '❯ new odd: change-cost▊', 'the ODD input row shows the normalized name');
|
|
406
|
+
const preview = previewText(view, 'path');
|
|
407
|
+
assert.equal(preview, path.join(WORKTREE_ROOT, 'change-cost'), 'the ODD names the directory with the dash');
|
|
408
|
+
view.handleInput('enter');
|
|
409
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/sign-in', odd: 'change-cost' }], 'the create makes what the path preview showed');
|
|
410
|
+
assert.equal(path.basename(preview), finished[0].odd, 'the previewed directory is the submitted ODD');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test('leading and trailing spaces still vanish: the trim keeps its place', () => {
|
|
414
|
+
const { view } = openPanel();
|
|
415
|
+
typeText(view, ' name ');
|
|
416
|
+
assert.equal(previewText(view, 'branch'), 'feat/name', 'the trim runs before the collapse, so no edge dash appears');
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
test('other characters keep their existing rules: a dot and an underscore are still fine', () => {
|
|
420
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui'] });
|
|
421
|
+
typeText(view, 'fix_it.now');
|
|
422
|
+
focusOdd(view);
|
|
423
|
+
view.handleInput('\x1b[B'); // down: login-ui
|
|
424
|
+
view.handleInput('enter');
|
|
425
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/fix_it.now', odd: 'login-ui' }], 'punctuation is untouched');
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test('a branch name that normalizes to nothing refuses with its own words', () => {
|
|
429
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui'] });
|
|
430
|
+
typeText(view, ' ');
|
|
431
|
+
assert.equal(previewText(view, 'branch'), 'feat/', 'an empty name still previews the type prefix');
|
|
432
|
+
focusOdd(view);
|
|
433
|
+
view.handleInput('\x1b[B'); // down: login-ui
|
|
434
|
+
view.handleInput('enter');
|
|
435
|
+
assert.deepEqual(finished, [], 'nothing is created');
|
|
436
|
+
assert.match(allText(renderedLines(view)), /cannot create: branch name is empty/);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
test('an ODD that normalizes to nothing refuses with its own words', () => {
|
|
158
440
|
const { view, finished } = openPanel();
|
|
159
|
-
|
|
160
|
-
|
|
441
|
+
typeText(view, 'sign-in');
|
|
442
|
+
focusOdd(view);
|
|
443
|
+
typeText(view, ' ');
|
|
444
|
+
assert.equal(previewText(view, 'path'), WORKTREE_ROOT, 'the path row stays neutral, not dashed');
|
|
445
|
+
view.handleInput('enter');
|
|
446
|
+
assert.deepEqual(finished, [], 'nothing is created');
|
|
447
|
+
assert.match(allText(renderedLines(view)), /cannot create: odd is empty/);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
describe('an ODD that already has a worktree is not offered (S5)', { concurrency: false }, () => {
|
|
452
|
+
test('the occupied ODD leaves the list while new odd stays first', () => {
|
|
453
|
+
const { view } = openPanel({
|
|
454
|
+
oddOptions: ['dagea', 'login-ui'],
|
|
455
|
+
occupiedPaths: [path.join(WORKTREE_ROOT, 'dagea')],
|
|
456
|
+
});
|
|
457
|
+
focusOdd(view);
|
|
458
|
+
const text = allText(renderedLines(view));
|
|
459
|
+
assert.ok(!text.includes(' dagea'), `the taken ODD is not offered\n${text}`);
|
|
460
|
+
assert.match(text, /❯ new odd/, 'new odd is still first and available');
|
|
461
|
+
assert.ok(text.includes(' login-ui'), 'the free ODD is still offered');
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test('a stale row for a removed checkout does not hide a free ODD', () => {
|
|
465
|
+
// The caller reconciles: a registry row whose directory is gone is not an
|
|
466
|
+
// occupied path, so the ODD is offered again.
|
|
467
|
+
const { view } = openPanel({ oddOptions: ['dagea'], occupiedPaths: [] });
|
|
468
|
+
focusOdd(view);
|
|
469
|
+
assert.ok(allText(renderedLines(view)).includes(' dagea'), 'the ODD is offered');
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
test('everything occupied still renders new odd and never an error', () => {
|
|
473
|
+
const { view, finished } = openPanel({
|
|
474
|
+
oddOptions: ['dagea'],
|
|
475
|
+
occupiedPaths: [path.join(WORKTREE_ROOT, 'dagea')],
|
|
476
|
+
});
|
|
477
|
+
focusOdd(view);
|
|
161
478
|
const text = allText(renderedLines(view));
|
|
162
|
-
assert.match(text,
|
|
163
|
-
assert.ok(
|
|
164
|
-
|
|
479
|
+
assert.match(text, /❯ new odd/);
|
|
480
|
+
assert.ok(!/cannot|error|no odds/i.test(text), `an emptied list is not a failure\n${text}`);
|
|
481
|
+
typeText(view, 'fresh');
|
|
482
|
+
view.handleInput('enter');
|
|
483
|
+
assert.deepEqual(finished, [], 'the branch name is still unanswered');
|
|
484
|
+
focusField(view, 'branch');
|
|
485
|
+
typeText(view, 'sign-in');
|
|
486
|
+
focusOdd(view);
|
|
487
|
+
view.handleInput('enter');
|
|
488
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/sign-in', odd: 'fresh' }], 'a new ODD is still enterable');
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
test('the filter is an aid, not the check: a taken ODD can still be answered', () => {
|
|
492
|
+
// The panel only hides; the create path owns the refusal. A caller that
|
|
493
|
+
// prefills a taken ODD still gets its completion.
|
|
494
|
+
const taken = path.join(WORKTREE_ROOT, 'dagea');
|
|
495
|
+
const { view, finished } = openPanel({ oddOptions: ['dagea'], occupiedPaths: [taken], initialOdd: 'dagea' });
|
|
496
|
+
assert.equal(previewText(view, 'path'), taken, 'the prefilled ODD still derives its path');
|
|
497
|
+
typeText(view, 'sign-in');
|
|
498
|
+
submit(view);
|
|
499
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/sign-in', odd: 'dagea' }], 'the create path owns the refusal');
|
|
165
500
|
});
|
|
501
|
+
});
|
|
166
502
|
|
|
167
|
-
|
|
503
|
+
describe('the create wizard previews the branch and the ODD separately', { concurrency: false }, () => {
|
|
504
|
+
test('an empty name refuses with its own words', () => {
|
|
505
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui'] });
|
|
506
|
+
focusOdd(view);
|
|
507
|
+
view.handleInput('\x1b[B'); // down: login-ui
|
|
508
|
+
view.handleInput('enter');
|
|
509
|
+
assert.deepEqual(finished, [], 'an empty branch name creates nothing');
|
|
510
|
+
assert.match(allText(renderedLines(view)), /cannot create: branch name is empty/);
|
|
511
|
+
assert.equal(previewText(view, 'branch'), 'feat/', 'the branch row stays readable, not blank');
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
test('an empty ODD refuses with its own words', () => {
|
|
168
515
|
const { view, finished } = openPanel();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
assert.
|
|
172
|
-
assert.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
assert.equal(previewText(view, 'path'),
|
|
182
|
-
|
|
183
|
-
assert.deepEqual(finished, [
|
|
516
|
+
typeText(view, 'login-ui');
|
|
517
|
+
submit(view);
|
|
518
|
+
assert.deepEqual(finished, [], 'an empty ODD creates nothing');
|
|
519
|
+
assert.match(allText(renderedLines(view)), /cannot create: odd is empty/);
|
|
520
|
+
assert.equal(previewText(view, 'path'), WORKTREE_ROOT, 'the path row stays neutral, not blank');
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
test('an ODD that is not one path segment refuses before creating', () => {
|
|
524
|
+
const { view, finished } = openPanel();
|
|
525
|
+
typeText(view, 'sign-in');
|
|
526
|
+
focusOdd(view);
|
|
527
|
+
typeText(view, '../escape');
|
|
528
|
+
assert.equal(previewText(view, 'path'), '-', 'an unusable ODD previews no path');
|
|
529
|
+
view.handleInput('enter');
|
|
530
|
+
assert.deepEqual(finished, [], 'an unusable ODD creates nothing');
|
|
531
|
+
assert.match(allText(renderedLines(view)), /cannot create: invalid odd name: "\.\.\/escape"/);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
test('choosing an existing ODD completes with it and writes nothing', () => {
|
|
535
|
+
const before = treeSnapshot(REPO);
|
|
536
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui', 'dagea'] });
|
|
537
|
+
typeText(view, 'sign-in');
|
|
538
|
+
focusOdd(view);
|
|
539
|
+
view.handleInput('\x1b[B'); // down: dagea (the list is sorted)
|
|
540
|
+
view.handleInput('enter');
|
|
541
|
+
assert.deepEqual(finished, [{ ok: true, branch: 'feat/sign-in', odd: 'dagea' }]);
|
|
542
|
+
assert.deepEqual(treeSnapshot(REPO), before, 'choosing an existing ODD writes nothing');
|
|
543
|
+
assert.equal(fs.existsSync(path.join(WORKTREE_ROOT, 'dagea')), false, 'no file or directory is created either');
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
test('escape cancels the whole form and writes nothing', () => {
|
|
547
|
+
const before = treeSnapshot(REPO);
|
|
548
|
+
const { view, finished } = openPanel({ oddOptions: ['login-ui'] });
|
|
549
|
+
typeText(view, 'sign-in');
|
|
550
|
+
focusOdd(view);
|
|
551
|
+
view.handleInput('\x1b[B');
|
|
552
|
+
view.handleInput('\x1b');
|
|
553
|
+
assert.deepEqual(finished, [null], 'escape is a cancel, exactly once');
|
|
554
|
+
assert.deepEqual(treeSnapshot(REPO), before, 'a cancel writes nothing');
|
|
555
|
+
assert.equal(fs.existsSync(WORKTREE_ROOT), false, 'a cancel creates nothing');
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
// The create and the preview must ask ONE function where a checkout goes.
|
|
559
|
+
test('the preview equals the path the create makes: the ODD, not the branch', () => {
|
|
560
|
+
const { view } = openPanel({ initialOdd: 'login-ui' });
|
|
561
|
+
assert.equal(previewText(view, 'branch'), 'feat/', 'the branch is the composed pair');
|
|
562
|
+
assert.equal(previewText(view, 'path'), createLib.worktreeDestinationPath(REPO, 'login-ui'));
|
|
563
|
+
assert.equal(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'login-ui'));
|
|
564
|
+
assert.notEqual(previewText(view, 'path'), path.join(WORKTREE_ROOT, 'feat-login'), 'the legacy slug is never previewed');
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// `main`'s documents are the list's source: the ref's tree, never the checkout
|
|
569
|
+
// the panel runs in, and never a failure — an absent directory, a missing `main`
|
|
570
|
+
// or a failing child is an empty list.
|
|
571
|
+
describe('the ODD list comes from main’s tree', { concurrency: false }, () => {
|
|
572
|
+
const mainListing = (stdout, status = 0) => async () => ({ status, stdout });
|
|
573
|
+
|
|
574
|
+
test('names main’s odd/tasks documents, without the extension, sorted', async () => {
|
|
575
|
+
const runAsync = mainListing('odd/tasks/worktree-tools-v2.md\0odd/tasks/dagea.md\0');
|
|
576
|
+
assert.deepEqual(await panel.listMainOddTasks({ runAsync, cwd: REPO }), ['dagea', 'worktree-tools-v2']);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
test('asks git for the main ref’s odd/tasks tree, never the working tree', async () => {
|
|
580
|
+
const calls = [];
|
|
581
|
+
const runAsync = async (bin, args, cwd) => {
|
|
582
|
+
calls.push({ bin, args, cwd });
|
|
583
|
+
return { status: 0, stdout: '' };
|
|
584
|
+
};
|
|
585
|
+
await panel.listMainOddTasks({ runAsync, cwd: REPO });
|
|
586
|
+
assert.equal(calls.length, 1, 'one bounded read, no second child');
|
|
587
|
+
assert.equal(calls[0].bin, 'git');
|
|
588
|
+
assert.equal(calls[0].cwd, REPO);
|
|
589
|
+
assert.deepEqual(calls[0].args, ['ls-tree', '-r', '--name-only', '-z', 'refs/heads/main', '--', 'odd/tasks']);
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
test('ignores everything that is not a document directly in odd/tasks', async () => {
|
|
593
|
+
const stdout = [
|
|
594
|
+
'odd/tasks/a.md',
|
|
595
|
+
'odd/tasks/notes.txt',
|
|
596
|
+
'odd/tasks/nested/b.md',
|
|
597
|
+
'odd/tasks/.hidden.md',
|
|
598
|
+
'odd/other.md',
|
|
599
|
+
'odd\\tasks\\windows.md',
|
|
600
|
+
'',
|
|
601
|
+
].join('\0');
|
|
602
|
+
assert.deepEqual(await panel.listMainOddTasks({ runAsync: mainListing(stdout), cwd: REPO }), ['a']);
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
test('a missing main, a failing child or no runner is an empty list, never an error', async () => {
|
|
606
|
+
assert.deepEqual(await panel.listMainOddTasks({ runAsync: mainListing('', 1), cwd: REPO }), []);
|
|
607
|
+
assert.deepEqual(await panel.listMainOddTasks({ runAsync: async () => { throw new Error('no git'); }, cwd: REPO }), []);
|
|
608
|
+
assert.deepEqual(await panel.listMainOddTasks({ runAsync: null, cwd: REPO }), []);
|
|
184
609
|
});
|
|
185
610
|
});
|