func generateSummary()

in cmd/generatechangelog/summary.go [148:195]


func generateSummary(manifest release.Manifest, annotations []changelog.Annotation) (releaseSummary, error) {
	summary := releaseSummary{
		ReleaseID: manifest.ID,
		Modules:   make(map[string]moduleSummary),
	}

	idToAnnotation := make(map[string]changelog.Annotation)
	for _, annotation := range annotations {
		idToAnnotation[annotation.ID] = annotation
	}

	hasDependencyBumps := false

	for modDir, mod := range manifest.Modules {
		ms := moduleSummary{
			ReleaseID:  manifest.ID,
			ModulePath: mod.ModulePath,
			Version:    mod.To,
		}
		for _, id := range mod.Annotations {
			an, ok := idToAnnotation[id]
			if !ok {
				continue
			}
			ms.Annotations = append(ms.Annotations, an)
		}
		if mod.Changes&release.DependencyUpdate != 0 {
			ms.Annotations = append(ms.Annotations, dependencyBump)
			hasDependencyBumps = true
		}
		sortAnnotations(ms.Annotations)
		summary.Modules[modDir] = ms
	}

	for _, annotation := range annotations {
		if annotation.Collapse {
			summary.General = append(summary.General, annotation)
		}
	}

	if hasDependencyBumps {
		summary.General = append(summary.General, dependencyBump)
	}

	sortAnnotations(summary.General)

	return summary, nil
}