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

Function preprocessProtectedFilesField

pkg/workflow/config_preprocessing.go:139–163  ·  view source on GitHub ↗

preprocessProtectedFilesField preprocesses the "protected-files" field in configData, handling both the legacy string-enum form and the new object form. String form (unchanged): "blocked", "allowed", or "fallback-to-issue". Object form: { policy: "blocked", exclude: ["AGENTS.md"] } - policy is opti

(configData map[string]any, debugLog *logger.Logger)

Source from the content-addressed store, hash-verified

137// When the string form is encountered the field is left unchanged and nil is returned.
138// The debugLog parameter is optional; pass nil to suppress debug output.
139func preprocessProtectedFilesField(configData map[string]any, debugLog *logger.Logger) []string {
140 if configData == nil {
141 return nil
142 }
143 raw, exists := configData["protected-files"]
144 if !exists || raw == nil {
145 return nil
146 }
147 pfMap, ok := raw.(map[string]any)
148 if !ok {
149 return nil
150 }
151 if policy, ok := pfMap["policy"].(string); ok && policy != "" {
152 configData["protected-files"] = policy
153 if debugLog != nil {
154 debugLog.Printf("protected-files object form: policy=%s", policy)
155 }
156 } else {
157 delete(configData, "protected-files")
158 if debugLog != nil {
159 debugLog.Print("protected-files object form: no policy, using default")
160 }
161 }
162 return parseStringSliceAny(pfMap["exclude"], debugLog)
163}
164
165// preprocessExpiresField handles the common expires field preprocessing pattern.
166// This function:

Calls 3

parseStringSliceAnyFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45