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

Function updateGitAttributes

pkg/cli/compile_infrastructure.go:15–44  ·  view source on GitHub ↗

updateGitAttributes ensures .gitattributes marks .lock.yml files as generated

(successCount int, actionCache *workflow.ActionCache, verbose bool)

Source from the content-addressed store, hash-verified

13
14// updateGitAttributes ensures .gitattributes marks .lock.yml files as generated
15func updateGitAttributes(successCount int, actionCache *workflow.ActionCache, verbose bool) error {
16 compileInfrastructureLog.Printf("Updating .gitattributes (compiled=%d, actionCache=%v)", successCount, actionCache != nil)
17
18 hasActionCacheEntries := actionCache != nil && len(actionCache.Entries) > 0
19
20 // Only update if we successfully compiled workflows or have action cache entries
21 if successCount > 0 || hasActionCacheEntries {
22 compileInfrastructureLog.Printf("Updating .gitattributes (compiled=%d, actionCache=%v)", successCount, hasActionCacheEntries)
23 updated, err := ensureGitAttributes()
24 if err != nil {
25 compileInfrastructureLog.Printf("Failed to update .gitattributes: %v", err)
26 if verbose {
27 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to update .gitattributes: %v", err)))
28 }
29 return err
30 }
31 if updated {
32 compileInfrastructureLog.Printf("Successfully updated .gitattributes")
33 if verbose {
34 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Updated .gitattributes to mark .lock.yml files as generated"))
35 }
36 } else {
37 compileInfrastructureLog.Print(".gitattributes already up to date")
38 }
39 } else {
40 compileInfrastructureLog.Print("Skipping .gitattributes update (no compiled workflows and no action cache entries)")
41 }
42
43 return nil
44}
45
46// saveActionCache saves the action cache after all compilations
47func saveActionCache(actionCache *workflow.ActionCache, verbose bool) error {

Callers 3

runPostProcessingFunction · 0.85
compileAllWorkflowFilesFunction · 0.85

Calls 5

FormatWarningMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
ensureGitAttributesFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected