The develop candidate leads with an advertised develop default rev

Round eight closes the stale-local class completely: the develop
candidate sits before the remote-default entries, so when origin/HEAD
itself points at develop, its name claim let a stale local develop win
over the fresher origin/develop. The candidate now leads with any
remote-advertised develop rev, exactly as the remote-default and
upstream candidates already lead with theirs. main/master were already
covered since their remote-default entries come first in the order.
Failing-first test forces local develop two commits behind.

Prepared with AI assistance (Claude Code), directed by @pbakaus.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-07-26 19:04:48 -07:00
co-authored by Claude Code
parent e2c1c43ee7
commit 01d5d357c5
2 changed files with 30 additions and 2 deletions
+6 -2
View File
@@ -168,10 +168,14 @@ function gitSignals(cwd) {
// even when the platform default (origin/HEAD) was never flipped off
// main; an existing develop therefore outranks the remote default. This
// is #302's own repro shape, and repos without develop are unaffected.
addCandidate('develop', revsFor('develop'));
// A remote's advertised default prefers its own remote-tracking rev over
// a possibly stale local checkout of the same name, for the same reason
// the upstream candidate leads with its rev.
// the upstream candidate leads with its rev. That applies to the develop
// candidate too when the remote default IS develop: it sits before the
// remote-default entries in the order, so it must lead with their rev
// itself or a stale local develop would win.
const advertisedRevs = (name) => remoteHeads.filter((head) => head.name === name).map((head) => head.rev);
addCandidate('develop', [...new Set([...advertisedRevs('develop'), ...revsFor('develop')])]);
for (const head of remoteHeads) addCandidate(head.name, [...new Set([head.rev, ...revsFor(head.name)])]);
for (const name of ['main', 'master']) addCandidate(name, revsFor(name));
for (const c of candidates) {
+24
View File
@@ -577,6 +577,30 @@ describe('gatherSignals', () => {
assert.deepEqual(s.git.changedFiles, ['src/Hero.tsx']);
});
it('a develop-pointing remote default outranks a stale local develop (#302)', async () => {
const { execFileSync } = await import('node:child_process');
const git = (...args) => execFileSync('git', args, { cwd: scratch, stdio: 'ignore' });
git('init', '-q', '-b', 'develop');
git('config', 'user.email', 't@example.com');
git('config', 'user.name', 'Test');
write('src/base.css', 'a{}\n');
git('add', '.');
git('commit', '-qm', 'A');
write('src/extra.css', 'b{}\n');
git('add', '.');
git('commit', '-qm', 'A2');
git('update-ref', 'refs/remotes/origin/develop', 'HEAD');
git('symbolic-ref', 'refs/remotes/origin/HEAD', 'refs/remotes/origin/develop');
git('checkout', '-q', '-b', 'feature/t');
write('src/Hero.tsx', 'export const Hero = () => null;\n');
git('add', '.');
git('commit', '-qm', 'feature work');
git('branch', '-f', 'develop', 'HEAD~2'); // local develop is stale at A
const s = await gatherSignals(scratch);
assert.equal(s.git.base, 'develop');
assert.deepEqual(s.git.changedFiles, ['src/Hero.tsx']);
});
it('never diffs one integration branch against another (#302)', async () => {
const { execFileSync } = await import('node:child_process');
const git = (...args) => execFileSync('git', args, { cwd: scratch, stdio: 'ignore' });