INNER CODE UNIT · Go
dedupeYAMLBlock
stacklok/toolhive · cmd/help/dedupe-enums/main.go:73
func dedupeYAMLBlock(match string) string {
g := yamlArray.FindStringSubmatch(match)
header, body := g[1], g[2]
lines := strings.Split(strings.TrimRight(body, "\n"), "\n")
period, ok := firstPeriodIfRepeated(lines)
if !ok {
return match
}
return header + strings.Join(period, "\n") + "\n"
}
// firstPeriodIfRepeated reports whether lines is the same block repeated
// back to back some whole number of times, returning one copy of that block
// if so. It only catches this shape (contiguous, order-preserved
// duplication), not any repeated multiset — if swag's bug ever reordered
// values within a later copy, this wouldn't fire. That matches the upstream
// bug: it re-appends the same const list, never reorders it. The repeat