Do not convert git tags when searching history

Currently, when the sem-ver processing is searching the git history,
it stores the canonical version and uses that as the tag, which is
fine if the project uses the canonical version as a tag. Instead,
return the original tag so that history can be correctly checked.

Change-Id: I1b83fc3dc3dd287ae3b23fd4cba07fdfdd673a7f
Closes-Bug: 1561254
This commit is contained in:
Steve Kowalik 2016-03-24 12:47:04 +11:00
parent 7cdcc023ca
commit b4d21581e2
2 changed files with 12 additions and 2 deletions

View File

@ -560,13 +560,16 @@ def _get_revno_and_last_tag(git_dir):
row_count = 0
for row_count, (ignored, tag_set, ignored) in enumerate(changelog):
version_tags = set()
semver_to_tag = dict()
for tag in list(tag_set):
try:
version_tags.add(version.SemanticVersion.from_pip_string(tag))
semver = version.SemanticVersion.from_pip_string(tag)
semver_to_tag[semver] = tag
version_tags.add(semver)
except Exception:
pass
if version_tags:
return max(version_tags).release_string(), row_count
return semver_to_tag[max(version_tags)], row_count
return "", row_count

View File

@ -497,6 +497,13 @@ class TestVersions(base.BaseTestCase):
version = packaging._get_version_from_git('1.2.3')
self.assertEqual('1.2.3', version)
def test_non_canonical_tagged_version_bump(self):
self.repo.commit()
self.repo.tag('1.4')
self.repo.commit('Sem-Ver: api-break')
version = packaging._get_version_from_git()
self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
def test_untagged_version_has_dev_version_postversion(self):
self.repo.commit()
self.repo.tag('1.2.3')