fix(#2988): local changeset/docs lint falls back to next, not main (#3095)

* fix(#2988): local changeset/docs lint falls back to next, not main

Both scripts/changeset/lint.cjs and scripts/lint-docs-required.cjs resolved
their diff base as GITHUB_BASE_REF || 'main'. GITHUB_BASE_REF is set only in
GitHub Actions; locally it falls back to 'main' (the release branch), which
lags far behind 'next' (the integration branch every PR targets). The
oversized diff range swept in every changeset fragment merged since the last
release, so the lint passed on the first fragment it saw regardless of
whether the current PR authored it — structurally vacuous.

Changed the fallback to 'next' (DEFAULT_BASE constant, exported from both
scripts for parity). CI behavior unchanged (GITHUB_BASE_REF is set there).
Added a parity test asserting both lints resolve the same base.

* chore(#2988): backfill changeset PR number 3095

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-05 19:27:07 -04:00
committed by GitHub
parent 955655407c
commit 2843e25bf3
4 changed files with 41 additions and 4 deletions

View File

@@ -12,6 +12,10 @@
* Tests assert on the typed verdict, never on free text.
*/
// #2988: the repo's integration/default branch — the base every PR targets.
// Used as the local fallback when GITHUB_BASE_REF is unset (CI sets it).
const DEFAULT_BASE = 'next';
const LINT_REASON = Object.freeze({
OK_FRAGMENT_PRESENT: 'ok_fragment_present',
OK_OPT_OUT_LABEL: 'ok_opt_out_label',
@@ -80,7 +84,10 @@ function main() {
labels = (event.pull_request?.labels || []).map((l) => l.name);
} catch { /* fall through */ }
}
const base = process.env.GITHUB_BASE_REF || 'main';
// #2988: local fallback must match the repo's integration branch (`next`),
// not the release branch (`main`). CI sets GITHUB_BASE_REF explicitly; the
// fallback only fires locally, where `next` is the base every PR targets.
const base = process.env.GITHUB_BASE_REF || DEFAULT_BASE;
let changedFiles = [];
try {
// Use execFileSync with an argv array — the base ref is interpolated
@@ -145,4 +152,4 @@ function main() {
if (require.main === module) runMain(main);
module.exports = { evaluateLint, LINT_REASON, OPT_OUT_LABEL, isUserFacing, isFragment };
module.exports = { evaluateLint, LINT_REASON, OPT_OUT_LABEL, isUserFacing, isFragment, DEFAULT_BASE };

View File

@@ -16,6 +16,10 @@
const { parseFragment, FRAGMENT_ERROR } = require('./changeset/parse.cjs');
const { ExitError, runMain } = require('./lib/cli-exit.cjs');
// #2988: the repo's integration/default branch — the base every PR targets.
// Used as the local fallback when GITHUB_BASE_REF is unset (CI sets it).
const DEFAULT_BASE = 'next';
const LINT_REASON = Object.freeze({
OK_NO_TRIGGERING_FRAGMENTS: 'ok_no_triggering_fragments',
OK_DOCS_UPDATED: 'ok_docs_updated',
@@ -149,7 +153,10 @@ function main() {
} catch { /* fall through */ }
}
const base = process.env.GITHUB_BASE_REF || 'main';
// #2988: local fallback must match the repo's integration branch (`next`),
// not the release branch (`main`). CI sets GITHUB_BASE_REF explicitly; the
// fallback only fires locally, where `next` is the base every PR targets.
const base = process.env.GITHUB_BASE_REF || DEFAULT_BASE;
let changedFiles = [];
try {
// execFileSync with argv — no shell, so a malicious GITHUB_BASE_REF
@@ -216,6 +223,7 @@ module.exports = {
OPT_OUT_LABEL,
TRIGGERING_TYPES,
FRAGMENT_ERROR,
DEFAULT_BASE,
isFragmentPath,
isDocsFile,
isExemptFragment,