MCPcopy
hub / github.com/grafana/tempo / GenerateSummary

Function GenerateSummary

tools/chloggen/internal/chlog/summary.go:58–93  ·  view source on GitHub ↗

GenerateSummary generates a changelog entry summary. Entries are grouped and ordered according to cfg.ChangeTypes; when none are configured, the built-in DefaultChangeTypes are used.

(version string, entries []*Entry, cfg *config.Config)

Source from the content-addressed store, hash-verified

56// ordered according to cfg.ChangeTypes; when none are configured, the built-in
57// DefaultChangeTypes are used.
58func GenerateSummary(version string, entries []*Entry, cfg *config.Config) (string, error) {
59 s := summary{
60 Version: version,
61 }
62
63 changeTypes := cfg.ChangeTypes
64 if len(changeTypes) == 0 {
65 changeTypes = DefaultChangeTypes
66 }
67
68 for _, ct := range changeTypes {
69 var grouped []*Entry
70 for _, entry := range entries {
71 if entry.ChangeType == ct.Key {
72 grouped = append(grouped, entry)
73 }
74 }
75 s.Groups = append(s.Groups, group{Heading: ct.Heading, Entries: grouped})
76
77 // Mirror built-in change types onto the named fields for backward compatibility.
78 switch ct.Key {
79 case Breaking:
80 s.BreakingChanges = grouped
81 case Deprecation:
82 s.Deprecations = grouped
83 case NewComponent:
84 s.NewComponents = grouped
85 case Enhancement:
86 s.Enhancements = grouped
87 case BugFix:
88 s.BugFixes = grouped
89 }
90 }
91
92 return s.String(cfg.SummaryTemplate)
93}
94
95// TemplateFuncMap returns a map of functions to be used in the template.
96func TemplateFuncMap() template.FuncMap {

Callers 4

updateCmdFunction · 0.92
TestSummaryFunction · 0.85
TestCustomSummaryFunction · 0.85

Calls 1

StringMethod · 0.95

Tested by 3

TestSummaryFunction · 0.68
TestCustomSummaryFunction · 0.68