From 9417c7d380d0d4ad5b267cfe71b01ee906dd3960 Mon Sep 17 00:00:00 2001 From: garrytan Date: Tue, 3 Nov 2026 03:37:02 +0000 Subject: [PATCH] Revert the resolveBase remote-prefix guard (regressed alice/base stacked bases); fringe case stays an open note Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- changelog.d/capy-bare-base-reads-originbase.md | 1 - lib/gate-diff/git.ts | 3 +-- test/stale-local-base.test.ts | 11 ----------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/changelog.d/capy-bare-base-reads-originbase.md b/changelog.d/capy-bare-base-reads-originbase.md index 79d474abe..1854b992c 100644 --- a/changelog.d/capy-bare-base-reads-originbase.md +++ b/changelog.d/capy-bare-base-reads-originbase.md @@ -1,3 +1,2 @@ - **A bare `--base main` reads origin/main in every review and ship bin (GST-1036).** `gstack-review-plan` now prints `REVIEW_BASE: ` and names a lagging local base on stderr. `gstack-banned-terms`, `gstack-prose-lint --base`, `gstack-docs-candidate`, `gstack-design-detect.ts scan --changed` and `gstack-pr-shots --base` no longer merge against a stale local main and report lines the branch only inherited. They all use the one resolver gstack-gate-diff already used. - **`gstack-diff-scope` stops treating authorship files as auth (GST-1065).** `author-spec.md`, `AUTHORS`, `authority.ts` and `coauthors.ts` no longer raise a docs diff to gate class. Every other name with auth in it still does, including `auth.ts`, `/auth/`, `oauth`, `nextauthmiddleware.ts` and camelCase names like `useAuth.ts`. -- **A remote-qualified `--base origin/main` is never re-qualified.** When the tracking ref is missing it resolves to nothing instead of trying `origin/origin/main`. diff --git a/lib/gate-diff/git.ts b/lib/gate-diff/git.ts index 76bda416a..daebe14d4 100644 --- a/lib/gate-diff/git.ts +++ b/lib/gate-diff/git.ts @@ -109,9 +109,8 @@ export function resolveBase(ref: string, cwd: string, head?: string): { ref: str if (!isBranchName(ref)) { const sha = direct(); return sha ? { ref, sha } : null; } const qualified = resolvesToCommit(`refs/remotes/` + ref, cwd); if (qualified) return { ref, sha: qualified }; - const remotes = remoteNames(cwd); - if (remotes.some((remote) => ref.startsWith(remote + '/'))) return null; const local = resolvesToCommit(`refs/heads/` + ref, cwd); + const remotes = remoteNames(cwd); const localRelated = !!local && related(local); const twin = (remote: string) => { const sha = resolvesToCommit(`refs/remotes/` + remote + '/' + ref, cwd); diff --git a/test/stale-local-base.test.ts b/test/stale-local-base.test.ts index 7cf99e1f1..5c2c749d6 100644 --- a/test/stale-local-base.test.ts +++ b/test/stale-local-base.test.ts @@ -11,7 +11,6 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { BANNED_TERMS_SCHEMA } from '../lib/banned-terms'; -import { resolveBase } from '../lib/gate-diff/git'; import { resolveCommit } from '../lib/pr-shots'; const BIN = path.join(import.meta.dir, '..', 'bin'); @@ -102,16 +101,6 @@ describe('a bare --base reads origin/ over a stale local branch (GST-1036) expect(r.err).toContain(`gstack-docs-candidate: ${NOTE}`); }, 120_000); - // Value: protects=a remote-qualified base is never re-qualified: origin/main reads refs/remotes/origin/main or nothing; - // fails_when=resolveBase falls through to refs/remotes/origin/origin/main when the tracking ref is missing; why_new=GST-1036 review (#3852 rule); seam=lib/gate-diff/git.ts resolveBase - test('resolveBase never re-qualifies origin/main when refs/remotes/origin/main is missing', () => { - const { work, sh, origin } = fixture(); - expect(resolveBase('origin/main', work, 'HEAD')?.sha).toBe(origin); - sh(work, 'git update-ref refs/remotes/origin/origin/main HEAD && git update-ref -d refs/remotes/origin/main'); - expect(resolveBase('origin/main', work, 'HEAD')).toBeNull(); - expect(resolveBase('main', work, 'HEAD')?.ref).toBe('main'); - }, 120_000); - // Value: protects=the PR screenshot's before side is origin's base, not a stale local copy; fails_when=resolveCommit reads refs/heads/main first; // why_new=GST-1036 sibling bin; seam=lib/pr-shots.ts resolveCommit test('gstack-pr-shots --base main reads origin/main; a sha resolves as given', () => {