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
This commit is contained in:
parent
5ded0ee1ff
commit
3793d87deb
@ -694,7 +694,7 @@ def _get_increment_kwargs(git_dir, tag):
|
|||||||
git_dir)
|
git_dir)
|
||||||
header_len = len('sem-ver:')
|
header_len = len('sem-ver:')
|
||||||
commands = [line[header_len:].strip() for line in changelog.split('\n')
|
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()
|
symbols = set()
|
||||||
for command in commands:
|
for command in commands:
|
||||||
symbols.update([symbol.strip() for symbol in command.split(',')])
|
symbols.update([symbol.strip() for symbol in command.split(',')])
|
||||||
|
@ -672,6 +672,20 @@ class TestVersions(base.BaseTestCase):
|
|||||||
version = packaging._get_version_from_git()
|
version = packaging._get_version_from_git()
|
||||||
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
|
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):
|
def test_tagged_version_has_tag_version(self):
|
||||||
self.repo.commit()
|
self.repo.commit()
|
||||||
self.repo.tag('1.2.3')
|
self.repo.tag('1.2.3')
|
||||||
|
Loading…
Reference in New Issue
Block a user