MCPcopy Create free account
hub / github.com/github/gh-aw / checkFrontmatterHashMismatch

Function checkFrontmatterHashMismatch

pkg/cli/run_push.go:592–631  ·  view source on GitHub ↗

checkFrontmatterHashMismatch checks if the frontmatter hash in the lock file matches the recomputed hash from the workflow file. Returns true if there's a mismatch (lock file is stale), false if they match. Note: This is used for logging/observability only. The compilation decision is made by collec

(workflowPath, lockFilePath string)

Source from the content-addressed store, hash-verified

590// Note: This is used for logging/observability only. The compilation decision
591// is made by collectWorkflowFiles, which always recompiles regardless of hash status.
592func checkFrontmatterHashMismatch(workflowPath, lockFilePath string) (bool, error) {
593 runPushLog.Printf("Checking frontmatter hash for %s", workflowPath)
594
595 // Read lock file to extract existing hash
596 lockContent, err := os.ReadFile(lockFilePath)
597 if err != nil {
598 return false, fmt.Errorf("failed to read lock file: %w", err)
599 }
600
601 // Extract hash from lock file using the workflow package function
602 metadata, _, err := workflow.ExtractMetadataFromLockFile(string(lockContent))
603 var existingHash string
604 if err == nil && metadata != nil {
605 existingHash = metadata.FrontmatterHash
606 }
607 if existingHash == "" {
608 runPushLog.Print("No frontmatter-hash found in lock file")
609 // No hash in lock file - consider it stale to regenerate with hash
610 return true, nil
611 }
612 runPushLog.Printf("Existing hash from lock file: %s", existingHash)
613
614 // Compute current hash from workflow file
615 cache := parser.NewImportCache("")
616 currentHash, err := parser.ComputeFrontmatterHashFromFile(workflowPath, cache)
617 if err != nil {
618 return false, fmt.Errorf("failed to compute frontmatter hash: %w", err)
619 }
620 runPushLog.Printf("Current hash from workflow: %s", currentHash)
621
622 // Compare hashes
623 mismatch := existingHash != currentHash
624 if mismatch {
625 runPushLog.Printf("Hash mismatch: existing=%s, current=%s", existingHash, currentHash)
626 } else {
627 runPushLog.Print("Hashes match")
628 }
629
630 return mismatch, nil
631}

Calls 6

NewImportCacheFunction · 0.92
PrintMethod · 0.80
PrintfMethod · 0.45
ErrorfMethod · 0.45