mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:50:43 +00:00
fix: include deleted files in changed lanes
This commit is contained in:
@@ -236,8 +236,8 @@ export function listChangedPathsFromGit(params) {
|
||||
return [
|
||||
...new Set([
|
||||
...rangePaths,
|
||||
...runGitNameOnlyDiff(["--cached", "--diff-filter=ACMR"], cwd),
|
||||
...runGitNameOnlyDiff(["--diff-filter=ACMR"], cwd),
|
||||
...runGitNameOnlyDiff(["--cached", "--diff-filter=ACMRD"], cwd),
|
||||
...runGitNameOnlyDiff(["--diff-filter=ACMRD"], cwd),
|
||||
...runGitLsFiles(["--others", "--exclude-standard"], cwd),
|
||||
]),
|
||||
].toSorted((left, right) => left.localeCompare(right));
|
||||
@@ -264,7 +264,7 @@ function runGitLsFiles(extraArgs, cwd = process.cwd()) {
|
||||
}
|
||||
|
||||
export function listStagedChangedPaths() {
|
||||
const output = execFileSync("git", ["diff", "--cached", "--name-only", "--diff-filter=ACMR"], {
|
||||
const output = execFileSync("git", ["diff", "--cached", "--name-only", "--diff-filter=ACMRD"], {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
maxBuffer: GIT_OUTPUT_MAX_BUFFER,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { mkdirSync, unlinkSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
@@ -83,6 +83,85 @@ describe("scripts/changed-lanes", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("includes deleted worktree files in the default local diff", () => {
|
||||
const dir = makeTempRepoRoot(tempDirs, "openclaw-changed-lanes-deleted-");
|
||||
git(dir, ["init", "-q", "--initial-branch=main"]);
|
||||
mkdirSync(path.join(dir, "src", "shared"), { recursive: true });
|
||||
writeFileSync(
|
||||
path.join(dir, "src", "shared", "obsolete.ts"),
|
||||
"export const value = 1;\n",
|
||||
"utf8",
|
||||
);
|
||||
git(dir, ["add", "src/shared/obsolete.ts"]);
|
||||
git(dir, [
|
||||
"-c",
|
||||
"user.email=test@example.com",
|
||||
"-c",
|
||||
"user.name=Test User",
|
||||
"commit",
|
||||
"-q",
|
||||
"-m",
|
||||
"initial",
|
||||
]);
|
||||
|
||||
unlinkSync(path.join(dir, "src", "shared", "obsolete.ts"));
|
||||
|
||||
const output = execFileSync(
|
||||
process.execPath,
|
||||
[path.join(repoRoot, "scripts", "changed-lanes.mjs"), "--json", "--base", "HEAD"],
|
||||
{
|
||||
cwd: dir,
|
||||
encoding: "utf8",
|
||||
env: createNestedGitEnv(),
|
||||
},
|
||||
);
|
||||
|
||||
expect(JSON.parse(output)).toMatchObject({
|
||||
paths: ["src/shared/obsolete.ts"],
|
||||
lanes: { core: true, coreTests: true },
|
||||
});
|
||||
});
|
||||
|
||||
it("includes deleted staged files in the staged diff", () => {
|
||||
const dir = makeTempRepoRoot(tempDirs, "openclaw-changed-lanes-staged-deleted-");
|
||||
git(dir, ["init", "-q", "--initial-branch=main"]);
|
||||
mkdirSync(path.join(dir, "src", "shared"), { recursive: true });
|
||||
writeFileSync(
|
||||
path.join(dir, "src", "shared", "obsolete.ts"),
|
||||
"export const value = 1;\n",
|
||||
"utf8",
|
||||
);
|
||||
git(dir, ["add", "src/shared/obsolete.ts"]);
|
||||
git(dir, [
|
||||
"-c",
|
||||
"user.email=test@example.com",
|
||||
"-c",
|
||||
"user.name=Test User",
|
||||
"commit",
|
||||
"-q",
|
||||
"-m",
|
||||
"initial",
|
||||
]);
|
||||
|
||||
unlinkSync(path.join(dir, "src", "shared", "obsolete.ts"));
|
||||
git(dir, ["add", "src/shared/obsolete.ts"]);
|
||||
|
||||
const output = execFileSync(
|
||||
process.execPath,
|
||||
[path.join(repoRoot, "scripts", "changed-lanes.mjs"), "--json", "--staged"],
|
||||
{
|
||||
cwd: dir,
|
||||
encoding: "utf8",
|
||||
env: createNestedGitEnv(),
|
||||
},
|
||||
);
|
||||
|
||||
expect(JSON.parse(output)).toMatchObject({
|
||||
paths: ["src/shared/obsolete.ts"],
|
||||
lanes: { core: true, coreTests: true },
|
||||
});
|
||||
});
|
||||
|
||||
it("ignores the explicit path separator", () => {
|
||||
const result = detectChangedLanes(["--", "scripts/test-live-acp-bind-docker.sh"]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user