feat(workflows): stamp runs with revision and improve history preview
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,12 +24,22 @@ export function parseWorkflowObject(content) {
|
||||
return yaml.parse(content) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop `enabled` before hashing so enable/disable does not create revision points.
|
||||
* @param {unknown} parsed
|
||||
*/
|
||||
function stripEnabledForHash(parsed) {
|
||||
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return parsed;
|
||||
const { enabled, ...rest } = parsed;
|
||||
return rest;
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA256 of normalized workflow content (YAML → object → canonical JSON).
|
||||
* @param {string} content
|
||||
*/
|
||||
export function workflowContentSha(content) {
|
||||
const parsed = parseWorkflowObject(content);
|
||||
const parsed = stripEnabledForHash(parseWorkflowObject(content));
|
||||
const canonical = canonicalize(parsed);
|
||||
const json = JSON.stringify(canonical);
|
||||
return createHash("sha256").update(json, "utf8").digest("hex");
|
||||
|
||||
Reference in New Issue
Block a user