summaryrefslogtreecommitdiff
path: root/packaging/release
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2019-03-14 11:18:14 -0700
committerMatt Clay <matt@mystile.com>2019-03-15 10:10:58 -0700
commit1b14a2d94610479a022f0da94b02c86ceb77c54f (patch)
tree5324fce1ba05795f5e4c9a6bc6390b948d5ade90 /packaging/release
parente0db8e6efbc2ac51d14b5e9503f067637a2882a3 (diff)
downloadansible-1b14a2d94610479a022f0da94b02c86ceb77c54f.tar.gz
[stable-2.7] Changelog lint and generation bug fixes. (#53792)
* Add missing dict entry for changelog generation. * Enforce str and list types on sections. * Check type of section list items. * Support non-ascii characters in changelogs.. (cherry picked from commit 90a38670be6a09dd51d2a44a253d681513e7ab95) Co-authored-by: Matt Clay <matt@mystile.com>
Diffstat (limited to 'packaging/release')
-rwxr-xr-xpackaging/release/changelogs/changelog.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/packaging/release/changelogs/changelog.py b/packaging/release/changelogs/changelog.py
index c11ceab222..4189c60e2c 100755
--- a/packaging/release/changelogs/changelog.py
+++ b/packaging/release/changelogs/changelog.py
@@ -24,6 +24,8 @@ try:
except ImportError:
argcomplete = None
+from ansible.module_utils.six import string_types
+
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
CHANGELOG_DIR = os.path.join(BASE_DIR, 'changelogs')
CONFIG_PATH = os.path.join(CHANGELOG_DIR, 'config.yaml')
@@ -298,14 +300,26 @@ class ChangelogFragmentLinter(object):
errors = []
for section, lines in fragment.content.items():
- if section not in self.config.sections:
- errors.append((fragment.path, 0, 0, 'invalid section: %s' % section))
+ if section == self.config.prelude_name:
+ if not isinstance(lines, string_types):
+ errors.append((fragment.path, 0, 0, 'section "%s" must be type str not %s' % (section, type(lines).__name__)))
+ else:
+ # doesn't account for prelude but only the RM should be adding those
+ if not isinstance(lines, list):
+ errors.append((fragment.path, 0, 0, 'section "%s" must be type list not %s' % (section, type(lines).__name__)))
+
+ if section not in self.config.sections:
+ errors.append((fragment.path, 0, 0, 'invalid section: %s' % section))
if isinstance(lines, list):
for line in lines:
+ if not isinstance(line, string_types):
+ errors.append((fragment.path, 0, 0, 'section "%s" list items must be type str not %s' % (section, type(line).__name__)))
+ continue
+
results = rstcheck.check(line, filename=fragment.path, report_level=docutils.utils.Reporter.WARNING_LEVEL)
errors += [(fragment.path, 0, 0, result[1]) for result in results]
- else:
+ elif isinstance(lines, string_types):
results = rstcheck.check(lines, filename=fragment.path, report_level=docutils.utils.Reporter.WARNING_LEVEL)
errors += [(fragment.path, 0, 0, result[1]) for result in results]