pi-odd-worktree 3.6.3 → 3.6.4
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.
|
@@ -7019,17 +7019,20 @@ function filesAllWorktrees(checkouts) {
|
|
|
7019
7019
|
* S9: the two numbers a scope row and its detail line show. The uncommitted set
|
|
7020
7020
|
* is the picker's own listing (`state !== "clean"`) and its newest mtime is "the
|
|
7021
7021
|
* age of the last modification"; the line above the footer is
|
|
7022
|
-
* `lib/files-scope-detail.js
|
|
7023
|
-
*
|
|
7024
|
-
* the
|
|
7022
|
+
* `lib/files-scope-detail.js`, measured against the SAME ref the scope's badges
|
|
7023
|
+
* came from (`filesComparison`): the principal checkout's own branch for every
|
|
7024
|
+
* worktree, and the remote branch the principal checkout tracks for the `main`
|
|
7025
|
+
* row. A read that failed leaves its fields absent, so the step paints less
|
|
7026
|
+
* instead of claiming a zero nobody measured.
|
|
7025
7027
|
*/
|
|
7026
7028
|
/**
|
|
7027
|
-
* S1/S2:
|
|
7028
|
-
*
|
|
7029
|
-
*
|
|
7030
|
-
*
|
|
7031
|
-
*
|
|
7032
|
-
*
|
|
7029
|
+
* S1/S2/S9: the ONE ref a worktree's committed work is measured against — the
|
|
7030
|
+
* branch the PRINCIPAL checkout has, whatever it is called (`master` in a
|
|
7031
|
+
* `master` repository), so a worktree is never diffed against a `main` that is
|
|
7032
|
+
* not the comparison. Both the badges and the scope's `↑`/`↓` line read this
|
|
7033
|
+
* value, so the count the step paints and the marks the picker paints can never
|
|
7034
|
+
* name two branches. `undefined` means "this scope reads no commits": the
|
|
7035
|
+
* principal checkout's badges are its own uncommitted work.
|
|
7033
7036
|
*/
|
|
7034
7037
|
function filesComparison(detailLib, scope) {
|
|
7035
7038
|
if (!scope || scope.kind !== 'worktree') return undefined;
|
|
@@ -7041,10 +7044,13 @@ function filesComparison(detailLib, scope) {
|
|
|
7041
7044
|
async function filesScopeFacts(index, detailLib, run, scope) {
|
|
7042
7045
|
const facts = {};
|
|
7043
7046
|
try {
|
|
7047
|
+
// ONE comparison for this scope, resolved once and handed to BOTH reads: the
|
|
7048
|
+
// badges below and the detail line after them describe the same branch.
|
|
7049
|
+
const comparison = filesComparison(detailLib, scope);
|
|
7044
7050
|
const listing = await index.listRepositoryEntries({
|
|
7045
7051
|
run,
|
|
7046
7052
|
cwd: scope.root,
|
|
7047
|
-
comparison
|
|
7053
|
+
comparison,
|
|
7048
7054
|
});
|
|
7049
7055
|
if (listing && listing.ok === true && Array.isArray(listing.entries)) {
|
|
7050
7056
|
let changed = 0;
|
|
@@ -7061,7 +7067,10 @@ async function filesScopeFacts(index, detailLib, run, scope) {
|
|
|
7061
7067
|
const loaded = await detailLib.loadScopeDetail({
|
|
7062
7068
|
run,
|
|
7063
7069
|
cwd: scope.root,
|
|
7064
|
-
|
|
7070
|
+
// A worktree measures against the very ref its badges came from; the
|
|
7071
|
+
// principal checkout, whose badges are its uncommitted work, measures
|
|
7072
|
+
// against the remote branch it tracks (S9).
|
|
7073
|
+
comparison: comparison === undefined ? detailLib.REMOTE_MAIN : comparison,
|
|
7065
7074
|
});
|
|
7066
7075
|
// The view paints the count and the age out of `detail`, and orders the rows
|
|
7067
7076
|
// by the scope's own `lastModifiedMs`, so both carry the same numbers.
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
|
|
15
15
|
const { formatAge } = require('./files-index.js');
|
|
16
16
|
|
|
17
|
-
// A worktree is compared with the
|
|
18
|
-
//
|
|
19
|
-
// `
|
|
17
|
+
// A worktree is compared with the branch the PRINCIPAL checkout has — never a
|
|
18
|
+
// constant, because a `master` repository has no `main` to measure against; the
|
|
19
|
+
// `main` row is compared with the remote main it tracks (S9). Those two choices
|
|
20
|
+
// belong to the wiring, and it feeds them in: `LOCAL_MAIN` is only the fallback it
|
|
21
|
+
// uses when Git reports no branch for the principal checkout (a detached one), so
|
|
22
|
+
// this module names no comparison of its own.
|
|
20
23
|
const LOCAL_MAIN = 'main';
|
|
21
24
|
const REMOTE_MAIN = 'origin/main';
|
|
22
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-odd-worktree",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4",
|
|
4
4
|
"description": "Pi package for odd-worktree: the Git worktree tools a Pi session uses (create and list the checkouts the agent works in), the /warp worktree panel, the /odd ODD viewer, and the /issues GitHub issue reader. Needs only Pi and git: no companion app, no extra service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -190,6 +190,15 @@ const scopeRowCount = (component, label) => scopeLabels(component)
|
|
|
190
190
|
.filter((row) => row === label
|
|
191
191
|
|| (row.startsWith(`${label} ±`) && /^±\d+ files?$/.test(row.slice(label.length + 1)))).length;
|
|
192
192
|
|
|
193
|
+
// The focused scope's detail line: the one body row directly above the footer, so a
|
|
194
|
+
// test can read what the step says about the row its cursor is on.
|
|
195
|
+
const detailLine = (component) => {
|
|
196
|
+
const rows = rowsOf(component);
|
|
197
|
+
const at = rows.findIndex((row) => row.includes('\u2191/\u2193 move'));
|
|
198
|
+
if (at <= 0) return '';
|
|
199
|
+
return rows[at - 1].replace(/^\u2502\s*/, '').replace(/\s*\u2502$/, '').trim();
|
|
200
|
+
};
|
|
201
|
+
|
|
193
202
|
// The ANSI-aware helpers the panel measures with; key matching falls back to the
|
|
194
203
|
// view's own spelled sequences, which is what a host without `matchesKey` has.
|
|
195
204
|
function visibleWidthOf(value) {
|
|
@@ -610,6 +619,9 @@ describe('the badges of a scope (S1-S4)', () => {
|
|
|
610
619
|
const step = host.mounts[0].component;
|
|
611
620
|
await waitFor(() => textOf(step).includes('on-master · feat/on-master'), 'the worktree row');
|
|
612
621
|
step.handleInput('\u001b[B');
|
|
622
|
+
// S9: the row measures against the branch the badges are measured with — the
|
|
623
|
+
// principal checkout's own — so the two never name different branches.
|
|
624
|
+
assert.match(detailLine(step), /\u2191\d+ master$/, 'the row names the branch the badges use');
|
|
613
625
|
step.handleInput('\r');
|
|
614
626
|
|
|
615
627
|
await waitFor(() => host.mounts.length >= 2, 'the picker over the worktree');
|
|
@@ -618,6 +630,54 @@ describe('the badges of a scope (S1-S4)', () => {
|
|
|
618
630
|
const text = textOf(picker);
|
|
619
631
|
assert.equal(badgeOf(text, 'x.js'), 'A', 'the committed file is marked against `master`');
|
|
620
632
|
assert.equal(badgeOf(text, 'a.js'), null);
|
|
633
|
+
assert.match(text, /^\u256d\u2500 \u273f Files \u00b7 .*on-master \u00b7 \u21911 master /m,
|
|
634
|
+
'and the picker\u2019s title carries the same branch and the same distance');
|
|
635
|
+
|
|
636
|
+
picker.handleInput('\u001b');
|
|
637
|
+
await running;
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
test('a worktree the principal branch already holds is measured against that branch, never a `main` it lacks', async () => {
|
|
641
|
+
// The reported defect: the principal checkout is on `master`, Git still holds a
|
|
642
|
+
// `main` this worktree is four commits ahead of, and `master` already CONTAINS
|
|
643
|
+
// those four commits. Read against that `main` the step claims `\u21914 main` while
|
|
644
|
+
// the badges — read against `master` — mark nothing, so the panel's two numbers
|
|
645
|
+
// describe two different branches. Both must be the principal checkout's own.
|
|
646
|
+
const repo = makeRepo({ branch: 'master' });
|
|
647
|
+
git(repo, ['branch', 'main', 'master']);
|
|
648
|
+
const worktree = addOwnedWorktree(repo, 'held', 'feat/held', 'main');
|
|
649
|
+
git(worktree, ['add', 'x.js']);
|
|
650
|
+
git(worktree, ['commit', '-m', 'commit x.js']);
|
|
651
|
+
fs.writeFileSync(path.join(worktree, 'two.js'), 'const two = 2;\n');
|
|
652
|
+
git(worktree, ['add', 'two.js']);
|
|
653
|
+
git(worktree, ['commit', '-m', 'add two.js']);
|
|
654
|
+
fs.writeFileSync(path.join(worktree, 'a.js'), 'const x = 3;\n');
|
|
655
|
+
git(worktree, ['commit', '-am', 'touch a.js']);
|
|
656
|
+
fs.appendFileSync(path.join(worktree, 'README.md'), 'more\n');
|
|
657
|
+
git(worktree, ['commit', '-am', 'touch README']);
|
|
658
|
+
git(repo, ['merge', '--no-ff', '-m', 'merge feat/held', 'feat/held']);
|
|
659
|
+
|
|
660
|
+
const { mod, commands } = await loadFilesExtension();
|
|
661
|
+
mod.setFilesTuiLoader(async () => helpers);
|
|
662
|
+
const host = mountHost();
|
|
663
|
+
const running = commands.get('files').handler('', ctxFor(repo, host.ui, { registeredRoots: [worktree] }));
|
|
664
|
+
|
|
665
|
+
await waitFor(() => host.mounts.length >= 1, 'the scope mount');
|
|
666
|
+
const step = host.mounts[0].component;
|
|
667
|
+
await waitFor(() => textOf(step).includes('held \u00b7 feat/held'), 'the worktree row');
|
|
668
|
+
step.handleInput('\u001b[B');
|
|
669
|
+
const detail = detailLine(step);
|
|
670
|
+
assert.match(detail, /\u2193\d+ master$/, 'the row measures against the branch the principal checkout has');
|
|
671
|
+
assert.equal(/\bmain\b/.test(detail), false, 'a `main` the badges never compared with is never named');
|
|
672
|
+
step.handleInput('\r');
|
|
673
|
+
|
|
674
|
+
await waitFor(() => host.mounts.length >= 2, 'the picker over the worktree');
|
|
675
|
+
const picker = host.mounts[1].component;
|
|
676
|
+
await waitFor(() => textOf(picker).includes('two.js'), 'the worktree listing');
|
|
677
|
+
const text = textOf(picker);
|
|
678
|
+
assert.equal(badgeOf(text, 'two.js'), null, 'nothing the principal branch already holds is marked');
|
|
679
|
+
assert.equal(badgeOf(text, 'a.js'), null, 'nor is a file it holds a newer state of');
|
|
680
|
+
assert.equal(/\u2191\d+/.test(text), false, 'the title claims no distance the badges do not share');
|
|
621
681
|
|
|
622
682
|
picker.handleInput('\u001b');
|
|
623
683
|
await running;
|