RunHashFrontmatter computes and prints the frontmatter hash for a workflow
(workflowPath string)
| 40 | |
| 41 | // RunHashFrontmatter computes and prints the frontmatter hash for a workflow |
| 42 | func RunHashFrontmatter(workflowPath string) error { |
| 43 | hashLog.Printf("Computing frontmatter hash for: %s", workflowPath) |
| 44 | |
| 45 | // Check if file exists |
| 46 | if _, err := os.Stat(workflowPath); os.IsNotExist(err) { |
| 47 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage("workflow file not found: "+workflowPath)) |
| 48 | return fmt.Errorf("workflow file not found: %s", workflowPath) |
| 49 | } |
| 50 | |
| 51 | // Compute hash |
| 52 | cache := parser.NewImportCache("") |
| 53 | hash, err := parser.ComputeFrontmatterHashFromFile(workflowPath, cache) |
| 54 | if err != nil { |
| 55 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error())) |
| 56 | return err |
| 57 | } |
| 58 | |
| 59 | // Print hash to stdout (for easy parsing by scripts) |
| 60 | fmt.Fprintln(os.Stdout, hash) |
| 61 | |
| 62 | return nil |
| 63 | } |
no test coverage detected