updateGitAttributes ensures .gitattributes marks .lock.yml files as generated
(successCount int, actionCache *workflow.ActionCache, verbose bool)
| 13 | |
| 14 | // updateGitAttributes ensures .gitattributes marks .lock.yml files as generated |
| 15 | func 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 |
| 47 | func saveActionCache(actionCache *workflow.ActionCache, verbose bool) error { |
no test coverage detected