fix: stabilize D601 env reuse planning

This commit is contained in:
lyon
2026-06-16 07:50:51 +08:00
parent acd3411ed0
commit 05f1e8ccd7
2 changed files with 24 additions and 4 deletions
+13 -3
View File
@@ -1572,12 +1572,22 @@ function prepareSourceScript() {
"import fs from \"node:fs\";",
"import { readStructuredFile } from \"./scripts/src/structured-config.mjs\";",
"const [catalogPath, deployPath, selectedServices] = process.argv.slice(2);",
"const ids = (doc) => (doc.services || []).map((service) => service.serviceId);",
"const selected = (selectedServices || \"\").split(\",\").filter(Boolean);",
"const ids = (doc) => (doc.services || []).map((service) => service.serviceId).filter(Boolean);",
"const selected = (selectedServices || \"\").split(\",\").map((item) => item.trim()).filter(Boolean);",
"const uniqueSorted = (items) => [...new Set(items)].sort();",
"const gitops = JSON.parse(fs.readFileSync(catalogPath, \"utf8\"));",
"const deploy = await readStructuredFile(process.cwd(), deployPath);",
"const expected = selected.length ? selected : ids(deploy);",
"if (JSON.stringify(ids(gitops)) !== JSON.stringify(expected)) process.exit(42);",
"const actual = ids(gitops);",
"const expectedSet = uniqueSorted(expected);",
"const actualSet = uniqueSorted(actual);",
"const sameServices = expectedSet.length === actualSet.length && expectedSet.every((item, index) => item === actualSet[index]);",
"if (!sameServices) {",
" const missing = expectedSet.filter((item) => !actualSet.includes(item));",
" const extra = actualSet.filter((item) => !expectedSet.includes(item));",
" console.error(JSON.stringify({ event: \"gitops-artifact-catalog\", phase: \"prepare-source\", status: \"ignored-stale\", reason: \"service-ids-mismatch\", expected, actual, missing, extra }));",
" process.exit(42);",
"}",
"NODE",
" then",
" cp /tmp/hwlab-gitops-artifact-catalog.json \"$catalog_path\"",
+11 -1
View File
@@ -666,10 +666,20 @@ export async function hashGitPaths(repoRoot, targetRef, paths, options = {}) {
async function hashEnvReuseInputs(repoRoot, targetRef, paths, recipe, options = {}) {
return stableHash({
gitPaths: await hashGitPaths(repoRoot, targetRef, paths, options),
envRecipe: recipe
envRecipe: envReuseIdentityRecipe(recipe)
});
}
function envReuseIdentityRecipe(recipe) {
const identity = JSON.parse(JSON.stringify(recipe ?? {}));
if (identity.downloadStack && typeof identity.downloadStack === "object") {
delete identity.downloadStack.httpProxy;
delete identity.downloadStack.httpsProxy;
delete identity.downloadStack.noProxy;
}
return identity;
}
export async function lastCommitForPaths(repoRoot, targetRef, paths) {
const normalizedPaths = uniqueSorted(paths.map(normalizeRepoPath).filter(Boolean));
if (normalizedPaths.length === 0) return null;