Skip to content

Commit 5b965aa

Browse files
committed
Address greptile's comment
1 parent 5aee411 commit 5b965aa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/codegen/codegen.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,11 +890,19 @@ func resolvedNameForComponent(section, name string, contentType ...string) strin
890890
}
891891

892892
// Fall back to prefix match for callers that don't specify content type.
893+
// Sort matching keys so the result is deterministic across runs.
893894
prefix := key + "/"
894-
for k, resolved := range globalState.resolvedNames {
895+
var matches []string
896+
for k := range globalState.resolvedNames {
895897
if strings.HasPrefix(k, prefix) {
896-
return resolved
898+
matches = append(matches, k)
899+
}
900+
}
901+
if len(matches) > 0 {
902+
if len(matches) > 1 {
903+
sort.Strings(matches)
897904
}
905+
return globalState.resolvedNames[matches[0]]
898906
}
899907

900908
return ""

0 commit comments

Comments
 (0)