From 54ee861b5faf85bea35361cdbb89f28bae15711b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 4 Feb 2019 14:47:20 -0700 Subject: [PATCH] Fix changelog generation for non-default versions Currently if you generate a changelog for r0.1.1 of an API, you'd get "No significant changes" which is wrong. You should get a real changelog for the version. This is now handled by generating a "preferred" changelog which acts as the default for version variables in the RST. Using a specific version's changelog is still supported for the rare cases where that is desired. --- scripts/templating/matrix_templates/sections.py | 2 +- scripts/templating/matrix_templates/units.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/templating/matrix_templates/sections.py b/scripts/templating/matrix_templates/sections.py index af4976744..4451d21d9 100644 --- a/scripts/templating/matrix_templates/sections.py +++ b/scripts/templating/matrix_templates/sections.py @@ -41,7 +41,7 @@ class MatrixSections(Sections): version_var = "%s_%s" % (spec_var, version) logger.info("Rendering changelog for %s" % version_var) rendered[version_var] = changelog - if version == "unstable": + if version == "preferred": rendered[spec_var] = changelog return rendered diff --git a/scripts/templating/matrix_templates/units.py b/scripts/templating/matrix_templates/units.py index 721501ff5..fd2618385 100644 --- a/scripts/templating/matrix_templates/units.py +++ b/scripts/templating/matrix_templates/units.py @@ -903,9 +903,17 @@ class MatrixUnits(Units): return schema - def load_changelogs(self): + def load_changelogs(self, substitutions): changelogs = {} + preferred_versions = { + "server_server": substitutions.get("%SERVER_RELEASE_LABEL%", "unstable"), + "client_server": substitutions.get("%CLIENT_RELEASE_LABEL%", "unstable"), + "identity_service": substitutions.get("%IDENTITY_RELEASE_LABEL%", "unstable"), + "push_gateway": substitutions.get("%PUSH_GATEWAY_RELEASE_LABEL%", "unstable"), + "application_service": substitutions.get("%APPSERVICE_RELEASE_LABEL%", "unstable"), + } + # Changelog generation is a bit complicated. We rely on towncrier to # generate the unstable/current changelog, but otherwise use the RST # edition to record historical changelogs. This is done by prepending @@ -1007,6 +1015,10 @@ class MatrixUnits(Units): title_part = keyword_versions[title_part] changelog = "".join(changelog_lines) changelogs[name][title_part.replace("^[a-zA-Z0-9]", "_").lower()] = changelog + preferred_changelog = changelogs[name]["unstable"] + if name in preferred_versions: + preferred_changelog = changelogs[name][preferred_versions[name]] + changelogs[name]["preferred"] = preferred_changelog return changelogs