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

Function checkLockFileStatus

pkg/cli/run_push.go:179–230  ·  view source on GitHub ↗

checkLockFileStatus checks the status of a workflow's lock file. This function is used to determine whether to show warnings to the user about outdated lock files. It does NOT control whether recompilation happens - collectWorkflowFiles always recompiles regardless of the hash status.

(workflowPath string)

Source from the content-addressed store, hash-verified

177// outdated lock files. It does NOT control whether recompilation happens -
178// collectWorkflowFiles always recompiles regardless of the hash status.
179func checkLockFileStatus(workflowPath string) (*LockFileStatus, error) {
180 runPushLog.Printf("Checking lock file status for: %s", workflowPath)
181
182 // Get absolute path for the workflow
183 absWorkflowPath, err := filepath.Abs(workflowPath)
184 if err != nil {
185 runPushLog.Printf("Failed to get absolute path for %s: %v", workflowPath, err)
186 return nil, fmt.Errorf("failed to get absolute path for workflow: %w", err)
187 }
188 runPushLog.Printf("Resolved absolute path: %s", absWorkflowPath)
189
190 // Validate the absolute path
191 absWorkflowPath, err = fileutil.ValidateAbsolutePath(absWorkflowPath)
192 if err != nil {
193 runPushLog.Printf("Invalid workflow path: %v", err)
194 return nil, fmt.Errorf("invalid workflow path: %w", err)
195 }
196
197 lockFilePath := stringutil.MarkdownToLockFile(absWorkflowPath)
198 runPushLog.Printf("Expected lock file path: %s", lockFilePath)
199 status := &LockFileStatus{
200 LockPath: lockFilePath,
201 }
202
203 // Check if lock file exists
204 if _, err := os.Stat(lockFilePath); err != nil {
205 if os.IsNotExist(err) {
206 status.Missing = true
207 runPushLog.Printf("Lock file missing: %s", lockFilePath)
208 return status, nil
209 }
210 runPushLog.Printf("Error stating lock file: %v", err)
211 return nil, fmt.Errorf("failed to stat lock file: %w", err)
212 }
213 runPushLog.Printf("Lock file exists: %s", lockFilePath)
214
215 // Lock file exists - check frontmatter hash
216 hashMismatch, err := checkFrontmatterHashMismatch(absWorkflowPath, lockFilePath)
217 if err != nil {
218 runPushLog.Printf("Error checking frontmatter hash: %v", err)
219 // Treat hash check error as outdated to be safe
220 status.Outdated = true
221 runPushLog.Printf("Lock file considered outdated due to hash check error")
222 } else if hashMismatch {
223 status.Outdated = true
224 runPushLog.Printf("Lock file outdated (frontmatter hash mismatch)")
225 } else {
226 runPushLog.Printf("Lock file is up-to-date (frontmatter hash matches)")
227 }
228
229 return status, nil
230}
231
232// collectImports recursively collects all imported files (transitive closure)
233func collectImports(workflowPath string, files map[string]struct {

Callers 1

RunWorkflowOnGitHubFunction · 0.85

Calls 5

ValidateAbsolutePathFunction · 0.92
MarkdownToLockFileFunction · 0.92
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected