diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-04-11 17:36:09 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-04-11 17:36:09 +0000 |
commit | d53ce060d42f9de1d186882c6d70b149f0f9a4d5 (patch) | |
tree | 1f1dc0b65feae4f596d8f6e46457caef4e8bde2b | |
parent | 5a21031398e426c20562417081eaabf2b535aca2 (diff) | |
parent | 3cc5af104eef83ccca1e46cbc8089b479f3ddd0f (diff) | |
download | pbr-d53ce060d42f9de1d186882c6d70b149f0f9a4d5.tar.gz |
Merge "Add Changelog build handling for invalid chars"
-rw-r--r-- | pbr/git.py | 22 | ||||
-rw-r--r-- | pbr/tests/test_packaging.py | 27 | ||||
-rw-r--r-- | pbr/tests/test_setup.py | 4 |
3 files changed, 49 insertions, 4 deletions
@@ -143,6 +143,27 @@ def get_git_short_sha(git_dir=None): return None +def _clean_changelog_message(msg): + """Cleans any instances of invalid sphinx wording. + + This removes any instances of invalid characters or wording + that can be interpreted by sphinx as a warning or error + when translating the Changelog into an HTML file for + documentation building within projects. + + Currently removes: + * Escapes any '_' that sphinx can interpret as a link + * Escapes any '*' with sphinx will interpret as a new commit + + """ + + msg = msg.replace('*', '\*') + msg = msg.replace('_', '\_') + msg = msg.replace('`', '\`') + + return msg + + def _iter_changelog(changelog): """Convert a oneline log iterator to formatted strings. @@ -166,6 +187,7 @@ def _iter_changelog(changelog): if not msg.startswith("Merge "): if msg.endswith("."): msg = msg[:-1] + msg = _clean_changelog_message(msg) yield current_release, "* %(msg)s\n" % dict(msg=msg) first_line = False diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index ab8ba49..69a8f79 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -270,8 +270,8 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase): def setUp(self): super(TestPackagingInGitRepoWithCommit, self).setUp() - repo = self.useFixture(TestRepo(self.package_dir)) - repo.commit() + self.repo = self.useFixture(TestRepo(self.package_dir)) + self.repo.commit() def test_authors(self): self.run_setup('sdist', allow_fail=False) @@ -287,6 +287,29 @@ class TestPackagingInGitRepoWithCommit(base.BaseTestCase): # One commit, something should be in the ChangeLog list self.assertNotEqual(body, '') + def test_changelog_handles_astrisk(self): + self.repo.commit(message_content="Allow *.openstack.org to work") + self.run_setup('sdist', allow_fail=False) + with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: + body = f.read() + self.assertIn('\*', body) + + def test_changelog_handles_dead_links_in_commit(self): + self.repo.commit(message_content="See os_ for to_do about qemu_.") + self.run_setup('sdist', allow_fail=False) + with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: + body = f.read() + self.assertIn('os\_', body) + self.assertIn('to\_do', body) + self.assertIn('qemu\_', body) + + def test_changelog_handles_backticks(self): + self.repo.commit(message_content="Allow `openstack.org` to `work") + self.run_setup('sdist', allow_fail=False) + with open(os.path.join(self.package_dir, 'ChangeLog'), 'r') as f: + body = f.read() + self.assertIn('\`', body) + def test_manifest_exclude_honoured(self): self.run_setup('sdist', allow_fail=False) with open(os.path.join( diff --git a/pbr/tests/test_setup.py b/pbr/tests/test_setup.py index 0930e35..3d2f401 100644 --- a/pbr/tests/test_setup.py +++ b/pbr/tests/test_setup.py @@ -165,7 +165,7 @@ class GitLogsTest(base.BaseTestCase): self.assertIn("------", changelog_contents) self.assertIn("Refactor hooks file", changelog_contents) self.assertIn( - "Bug fix: create_stack() fails when waiting", + "Bug fix: create\_stack() fails when waiting", changelog_contents) self.assertNotIn("Refactor hooks file.", changelog_contents) self.assertNotIn("182feb3", changelog_contents) @@ -179,7 +179,7 @@ class GitLogsTest(base.BaseTestCase): self.assertNotIn("ev)il", changelog_contents) self.assertNotIn("e(vi)l", changelog_contents) self.assertNotIn('Merge "', changelog_contents) - self.assertNotIn('1_foo.1', changelog_contents) + self.assertNotIn('1\_foo.1', changelog_contents) def test_generate_authors(self): author_old = u"Foo Foo <email@foo.com>" |