
























@@ -1,3 +1,4 @@
1+import { execFileSync } from "node:child_process";
12import fs from "node:fs";
23import os from "node:os";
34import path from "node:path";
@@ -19,6 +20,7 @@ const { detectChangedScope, listChangedPaths } =
1920};
20212122const markerPaths: string[] = [];
23+const tempDirs: string[] = [];
22242325afterEach(() => {
2426for (const markerPath of markerPaths) {
@@ -27,8 +29,25 @@ afterEach(() => {
2729} catch {}
2830}
2931markerPaths.length = 0;
32+for (const tempDir of tempDirs) {
33+fs.rmSync(tempDir, { force: true, recursive: true });
34+}
35+tempDirs.length = 0;
3036});
313738+function parseGitHubOutput(output: string): Record<string, string> {
39+return Object.fromEntries(
40+output
41+.trim()
42+.split("\n")
43+.filter(Boolean)
44+.map((line) => {
45+const separator = line.indexOf("=");
46+return [line.slice(0, separator), line.slice(separator + 1)];
47+}),
48+);
49+}
50+3251describe("detectChangedScope", () => {
3352it("fails safe when no paths are provided", () => {
3453expect(detectChangedScope([])).toEqual({
@@ -333,4 +352,33 @@ describe("detectChangedScope", () => {
333352expect(() => listChangedPaths(injectedBase, "HEAD")).toThrow();
334353expect(fs.existsSync(markerPath)).toBe(false);
335354});
355+356+it("keeps direct CLI preflight empty diffs as no-op scope", () => {
357+const repoDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-ci-scope-empty-"));
358+tempDirs.push(repoDir);
359+const outputPath = path.join(repoDir, "github-output.txt");
360+const scriptPath = path.resolve("scripts/ci-changed-scope.mjs");
361+362+execFileSync("git", ["init", "-b", "main"], { cwd: repoDir });
363+execFileSync("git", ["config", "user.email", "ci@example.invalid"], { cwd: repoDir });
364+execFileSync("git", ["config", "user.name", "CI"], { cwd: repoDir });
365+fs.writeFileSync(path.join(repoDir, "README.md"), "test\n", "utf8");
366+execFileSync("git", ["add", "README.md"], { cwd: repoDir });
367+execFileSync("git", ["commit", "-m", "test"], { cwd: repoDir });
368+369+execFileSync(process.execPath, [scriptPath, "--base", "HEAD", "--head", "HEAD"], {
370+cwd: repoDir,
371+env: { ...process.env, GITHUB_OUTPUT: outputPath },
372+});
373+374+expect(parseGitHubOutput(fs.readFileSync(outputPath, "utf8"))).toEqual({
375+run_node: "false",
376+run_macos: "false",
377+run_android: "false",
378+run_windows: "false",
379+run_skills_python: "false",
380+run_changed_smoke: "false",
381+run_control_ui_i18n: "false",
382+});
383+});
336384});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。