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

Function hasExitedBlock

pkg/cli/yaml_frontmatter_utils.go:69–84  ·  view source on GitHub ↗

hasExitedBlock checks if we've left a YAML block (found a line with same or less indentation that's a key)

(line, blockIndent string)

Source from the content-addressed store, hash-verified

67
68// hasExitedBlock checks if we've left a YAML block (found a line with same or less indentation that's a key)
69func hasExitedBlock(line, blockIndent string) bool {
70 trimmed := strings.TrimSpace(line)
71 if trimmed == "" {
72 return false
73 }
74
75 currentIndent := getIndentation(line)
76
77 // If it's a comment, check indentation to see if we've exited
78 if strings.HasPrefix(trimmed, "#") {
79 return len(currentIndent) <= len(blockIndent)
80 }
81
82 // For regular lines, we've exited if indentation is same or less and it contains a colon
83 return len(currentIndent) <= len(blockIndent) && strings.Contains(line, ":")
84}
85
86// findAndReplaceInLine replaces oldKey with newKey in a YAML line, preserving value and comments
87func findAndReplaceInLine(line, oldKey, newKey string) (string, bool) {

Calls 1

getIndentationFunction · 0.85

Tested by 1

TestHasExitedBlockFunction · 0.68