fix: make sync pull produce consistent wmill-lock.yaml hashes (#8854)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-04-16 17:57:11 +02:00
committed by GitHub
parent 0773b5bc5d
commit 625d23fc85
4 changed files with 17 additions and 3 deletions
+6 -1
View File
@@ -92,7 +92,12 @@ async function generateAppHash(
}
}
return { ...hashes, [TOP_HASH]: await generateHash(JSON.stringify(hashes)) };
// Sort keys so the top hash is deterministic regardless of filesystem readdir order
const sortedHashes: Record<string, string> = {};
for (const k of Object.keys(hashes).sort()) {
sortedHashes[k] = hashes[k];
}
return { ...sortedHashes, [TOP_HASH]: await generateHash(JSON.stringify(sortedHashes)) };
}
/**
+6 -1
View File
@@ -51,7 +51,12 @@ async function generateFlowHash(
);
}
}
return { ...hashes, [TOP_HASH]: await generateHash(JSON.stringify(hashes)) };
// Sort keys so the top hash is deterministic regardless of filesystem readdir order
const sortedHashes: Record<string, string> = {};
for (const k of Object.keys(hashes).sort()) {
sortedHashes[k] = hashes[k];
}
return { ...sortedHashes, [TOP_HASH]: await generateHash(JSON.stringify(sortedHashes)) };
}
/**
* Result of generating flow locks, including which scripts were updated
+1
View File
@@ -2553,6 +2553,7 @@ export async function pull(
),
);
}
}
function prettyChanges(
+4 -1
View File
@@ -380,7 +380,10 @@ export async function generateScriptMetadataInternal(
}
}
const metadataContentUsedForHash = newMetadataContent;
// When justUpdateMetadataLock (sync pull), the metadata file is NOT rewritten,
// so use the raw file content for hashing to avoid YAML round-trip differences
// (e.g. hand-edited YAML that serializes differently after parse + stringify).
const metadataContentUsedForHash = justUpdateMetadataLock ? metadataContent : newMetadataContent;
hash = await generateScriptHash(
depsForHash,