mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:10:58 +00:00
refactor: deduplicate changed lane detection
This commit is contained in:
@@ -203,6 +203,21 @@ export function detectChangedLanes(changedPaths, options = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {{ paths: string[]; base: string; head?: string; staged?: boolean }} params
|
||||||
|
* @returns {ChangedLaneResult}
|
||||||
|
*/
|
||||||
|
export function detectChangedLanesForPaths(params) {
|
||||||
|
const packageJsonChangeKind = params.paths.includes("package.json")
|
||||||
|
? classifyPackageJsonChangeFromGit({
|
||||||
|
base: params.base,
|
||||||
|
head: params.head,
|
||||||
|
staged: params.staged,
|
||||||
|
})
|
||||||
|
: null;
|
||||||
|
return detectChangedLanes(params.paths, { packageJsonChangeKind });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{ base: string; head?: string; includeWorktree?: boolean; cwd?: string }} params
|
* @param {{ base: string; head?: string; includeWorktree?: boolean; cwd?: string }} params
|
||||||
* @returns {string[]}
|
* @returns {string[]}
|
||||||
@@ -458,14 +473,12 @@ if (isDirectRun()) {
|
|||||||
: args.staged
|
: args.staged
|
||||||
? listStagedChangedPaths()
|
? listStagedChangedPaths()
|
||||||
: listChangedPathsFromGit({ base: args.base, head: args.head });
|
: listChangedPathsFromGit({ base: args.base, head: args.head });
|
||||||
const packageJsonChangeKind = paths.includes("package.json")
|
const result = detectChangedLanesForPaths({
|
||||||
? classifyPackageJsonChangeFromGit({
|
paths,
|
||||||
base: args.base,
|
base: args.base,
|
||||||
head: args.head,
|
head: args.head,
|
||||||
staged: args.staged,
|
staged: args.staged,
|
||||||
})
|
});
|
||||||
: null;
|
|
||||||
const result = detectChangedLanes(paths, { packageJsonChangeKind });
|
|
||||||
if (args.githubOutput) {
|
if (args.githubOutput) {
|
||||||
writeChangedLaneGitHubOutput(result);
|
writeChangedLaneGitHubOutput(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { performance } from "node:perf_hooks";
|
import { performance } from "node:perf_hooks";
|
||||||
import {
|
import {
|
||||||
classifyPackageJsonChangeFromGit,
|
detectChangedLanesForPaths,
|
||||||
detectChangedLanes,
|
|
||||||
listChangedPathsFromGit,
|
listChangedPathsFromGit,
|
||||||
listStagedChangedPaths,
|
listStagedChangedPaths,
|
||||||
normalizeChangedPath,
|
normalizeChangedPath,
|
||||||
@@ -285,14 +284,12 @@ if (isDirectRun()) {
|
|||||||
: args.staged
|
: args.staged
|
||||||
? listStagedChangedPaths()
|
? listStagedChangedPaths()
|
||||||
: listChangedPathsFromGit({ base: args.base, head: args.head });
|
: listChangedPathsFromGit({ base: args.base, head: args.head });
|
||||||
const packageJsonChangeKind = paths.includes("package.json")
|
const result = detectChangedLanesForPaths({
|
||||||
? classifyPackageJsonChangeFromGit({
|
paths,
|
||||||
base: args.base,
|
base: args.base,
|
||||||
head: args.head,
|
head: args.head,
|
||||||
staged: args.staged,
|
staged: args.staged,
|
||||||
})
|
});
|
||||||
: null;
|
|
||||||
const result = detectChangedLanes(paths, { packageJsonChangeKind });
|
|
||||||
process.exitCode = await runChangedCheck(result, {
|
process.exitCode = await runChangedCheck(result, {
|
||||||
...args,
|
...args,
|
||||||
explicitPaths: args.paths.length > 0,
|
explicitPaths: args.paths.length > 0,
|
||||||
|
|||||||
@@ -734,9 +734,6 @@ export function resolveChangedTestTargetPlan(changedPaths, options = {}) {
|
|||||||
targets.push(changedPath);
|
targets.push(changedPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (useBroadFallback && changedLanes.lanes.all) {
|
|
||||||
return { mode: "broad", targets: [] };
|
|
||||||
}
|
|
||||||
if (useBroadFallback && changedLanes.extensionImpactFromCore) {
|
if (useBroadFallback && changedLanes.extensionImpactFromCore) {
|
||||||
targets.push("extensions");
|
targets.push("extensions");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user