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

Function removeEmptyEngineEnvBlock

pkg/cli/codemod_engine_env_secrets.go:226–253  ·  view source on GitHub ↗
(lines []string)

Source from the content-addressed store, hash-verified

224}
225
226func removeEmptyEngineEnvBlock(lines []string) []string {
227 result := make([]string, 0, len(lines))
228 for i := range lines {
229 line := lines[i]
230 trimmed := strings.TrimSpace(line)
231 if trimmed == "env:" {
232 envIndent := getIndentation(line)
233 hasValues := false
234 j := i + 1
235 for ; j < len(lines); j++ {
236 t := strings.TrimSpace(lines[j])
237 if t == "" {
238 continue
239 }
240 if len(getIndentation(lines[j])) <= len(envIndent) {
241 break
242 }
243 hasValues = true
244 break
245 }
246 if !hasValues {
247 continue
248 }
249 }
250 result = append(result, line)
251 }
252 return result
253}
254
255// getTopLevelEnvSecretsGuidedErrorCodemod creates a codemod that emits a guided error
256// when secrets are detected in the top-level env: block. Unlike the engine.env codemod

Callers 1

Calls 1

getIndentationFunction · 0.85

Tested by

no test coverage detected