Skip to content

Commit 986304e

Browse files
authored
fix(tooling): format files in changed checks (#104605)
1 parent d4adddb commit 986304e

4 files changed

Lines changed: 65 additions & 2 deletions

File tree

‎docs/ci.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Canonical-repo CI keeps Blacksmith as the default runner path for normal push an
186186

187187
```bash
188188
pnpm changed:lanes # inspect the local changed-lane classifier for origin/main...HEAD
189-
pnpm check:changed # smart local check gate: changed typecheck/lint/guards by boundary lane
189+
pnpm check:changed # smart local check gate: changed formatting/typecheck/lint/guards by boundary lane
190190
pnpm check # fast local gate: prod tsgo + sharded lint + parallel fast guards
191191
pnpm check:test-types
192192
pnpm check:timed # same gate with per-stage timings

‎docs/reference/test.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Test wrapper runs end with a short `[test] passed|failed|skipped ... in ...` sum
8686
| `pnpm test:coverage` | Emits an informational V8 coverage report for the default unit lane (`vitest.unit.config.ts`); no coverage thresholds are enforced. |
8787
| `pnpm test:coverage:changed` | Unit coverage only for files changed since `origin/main`. |
8888
| `pnpm changed:lanes` | Shows the architectural lanes triggered by the diff against `origin/main`. |
89-
| `pnpm check:changed` | Delegates to Crabbox/Testbox by default outside CI, then runs the smart changed check gate inside the remote child: typecheck, lint, and guard commands for affected lanes. Does not run Vitest; use `pnpm test:changed` or `pnpm test <target>` for test proof. |
89+
| `pnpm check:changed` | Delegates to Crabbox/Testbox by default outside CI, then runs the smart changed check gate inside the remote child: formatting plus typecheck, lint, and guard commands for affected lanes. Does not run Vitest; use `pnpm test:changed` or `pnpm test <target>` for test proof. |
9090

9191
## Shared test state and process helpers
9292

‎scripts/check-changed.mjs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ export function createChangedCheckPlan(result, options = {}) {
287287
add("plugin-sdk wildcard re-exports", ["lint:extensions:no-plugin-sdk-wildcard-reexports"]);
288288
add("duplicate scan target coverage", ["dup:check:coverage"]);
289289
add("dependency pin guard", ["deps:pins:check"]);
290+
if (result.paths.length > 0) {
291+
add("format changed files", [
292+
"format:check",
293+
"--no-error-on-unmatched-pattern",
294+
"--",
295+
...result.paths,
296+
]);
297+
}
290298
const shrinkwrapGuardCommand = createShrinkwrapGuardCommand(result.paths);
291299
if (shrinkwrapGuardCommand) {
292300
addCommand(

‎test/scripts/changed-lanes.test.ts‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,55 @@ describe("scripts/changed-lanes", () => {
406406
}
407407
});
408408

409+
it("includes committed and untracked added files in the changed format check", () => {
410+
const dir = makeTempRepoRoot(tempDirs, "openclaw-changed-lanes-added-format-");
411+
git(dir, ["init", "-q", "--initial-branch=main"]);
412+
writeRepoFile(dir, "README.md", "initial\n");
413+
git(dir, ["add", "."]);
414+
git(dir, [
415+
"-c",
416+
417+
"-c",
418+
"user.name=Test User",
419+
"commit",
420+
"-q",
421+
"-m",
422+
"initial",
423+
]);
424+
git(dir, ["update-ref", "refs/remotes/origin/main", "HEAD"]);
425+
git(dir, ["switch", "-q", "-c", "feature"]);
426+
writeRepoFile(dir, "src/committed.test.ts", "export const committed={value:1};\n");
427+
git(dir, ["add", "src/committed.test.ts"]);
428+
git(dir, [
429+
"-c",
430+
431+
"-c",
432+
"user.name=Test User",
433+
"commit",
434+
"-q",
435+
"-m",
436+
"add test",
437+
]);
438+
writeRepoFile(dir, "src/untracked.test.ts", "export const untracked={value:1};\n");
439+
writeRepoFile(dir, "--help", "ignored\n");
440+
441+
const paths = listChangedPathsFromGit({ base: "origin/main", cwd: dir });
442+
const plan = createChangedCheckPlan(detectChangedLanes(paths));
443+
444+
expect(paths).toEqual(["--help", "src/committed.test.ts", "src/untracked.test.ts"]);
445+
expect(plan.commands.find((command) => command.name === "format changed files")).toEqual({
446+
name: "format changed files",
447+
args: [
448+
"format:check",
449+
"--no-error-on-unmatched-pattern",
450+
"--",
451+
"--help",
452+
"src/committed.test.ts",
453+
"src/untracked.test.ts",
454+
],
455+
});
456+
});
457+
409458
it("uses the merge commit first parent instead of a stale PR payload base", () => {
410459
const { dir, staleBase } = createSyntheticMergeRepo("openclaw-changed-lanes-merge-");
411460

@@ -1128,6 +1177,7 @@ describe("scripts/changed-lanes", () => {
11281177
"plugin-sdk wildcard re-exports",
11291178
"duplicate scan target coverage",
11301179
"dependency pin guard",
1180+
"format changed files",
11311181
"package patch guard",
11321182
"test temp creation report (warning-only)",
11331183
"typecheck core tests",
@@ -1411,6 +1461,7 @@ describe("scripts/changed-lanes", () => {
14111461
"lint:extensions:no-plugin-sdk-wildcard-reexports",
14121462
"dup:check:coverage",
14131463
"deps:pins:check",
1464+
"format:check",
14141465
"scripts/generate-npm-shrinkwrap.mjs",
14151466
"deps:patches:check",
14161467
"release-metadata:check",
@@ -1926,6 +1977,10 @@ describe("scripts/changed-lanes", () => {
19261977
},
19271978
{ name: "duplicate scan target coverage", args: ["dup:check:coverage"] },
19281979
{ name: "dependency pin guard", args: ["deps:pins:check"] },
1980+
{
1981+
name: "format changed files",
1982+
args: ["format:check", "--no-error-on-unmatched-pattern", "--", "docs/ci.md", "README.md"],
1983+
},
19291984
{ name: "package patch guard", args: ["deps:patches:check"] },
19301985
]);
19311986
});

0 commit comments

Comments
 (0)