diff options
author | Chris Dohmen <chris.dohmen@sciencelogic.com> | 2022-06-03 09:11:41 -0400 |
---|---|---|
committer | Chris Dohmen <chris.dohmen@sciencelogic.com> | 2022-06-03 09:21:25 -0400 |
commit | 3793d87deb762f773eda1622ed87941c24bc253d (patch) | |
tree | 2f896cdc1e91adaab09034e158c349652720325b | |
parent | 5ded0ee1ff7236aa6bdc94cf5f4426b3816c98ef (diff) | |
download | pbr-3793d87deb762f773eda1622ed87941c24bc253d.tar.gz |
Allow leading spaces when determining symbols
Update the logic that checks for sem-ver to strip out leading spaces.
This helps solve an issue during automated squashes appending a tab
character to the start of each line in a commit message.
Closes-Bug: #1977479
Change-Id: I6f56500c366fd9610d98507f01e8af21862e4421
-rw-r--r-- | pbr/packaging.py | 2 | ||||
-rw-r--r-- | pbr/tests/test_packaging.py | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py index 8577b53..8e9c9ae 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -694,7 +694,7 @@ def _get_increment_kwargs(git_dir, tag): git_dir) header_len = len('sem-ver:') commands = [line[header_len:].strip() for line in changelog.split('\n') - if line.lower().startswith('sem-ver:')] + if line.lower().strip().startswith('sem-ver:')] symbols = set() for command in commands: symbols.update([symbol.strip() for symbol in command.split(',')]) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index c92ea9b..346540b 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -672,6 +672,20 @@ class TestVersions(base.BaseTestCase): version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1')) + def test_leading_space(self): + self.repo.commit() + self.repo.tag('1.2.3') + self.repo.commit(' sem-ver: api-break') + version = packaging._get_version_from_git() + self.assertThat(version, matchers.StartsWith('2.0.0.dev1')) + + def test_leading_characters_symbol_not_found(self): + self.repo.commit() + self.repo.tag('1.2.3') + self.repo.commit(' ssem-ver: api-break') + version = packaging._get_version_from_git() + self.assertThat(version, matchers.StartsWith('1.2.4.dev1')) + def test_tagged_version_has_tag_version(self): self.repo.commit() self.repo.tag('1.2.3') |