aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Trochalakis <ctrochalakis@debian.org>2017-07-08 15:25:32 +0300
committerGuido Günther <agx@sigxcpu.org>2017-07-10 18:19:10 +0200
commit61f4625eb0b7cdd0277249aa592427e60500086d (patch)
tree3bae070c093842b2d641ac26e82fa432d1e4902a
parent0388f9e397e591cd4de7de019e54d10548049943 (diff)
dch: unmangle upstream_tag when guessing upstream version
Running `gbp dch` with a mangled upstream tag resulted in a KeyError while trying to build a tag pattern. Signed-off-by: Guido Günther <agx@sigxcpu.org>
-rw-r--r--gbp/deb/git.py2
-rw-r--r--tests/03_test_dch_guess_version.py19
2 files changed, 20 insertions, 1 deletions
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index 0a2bddc..edc8368 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -114,7 +114,7 @@ class DebianGitRepository(GitRepository):
@returns: a new debian version
@raises GitRepositoryError: if no upstream tag was found
"""
- pattern = upstream_tag_format % dict(version='*')
+ pattern = self._unmangle_format(upstream_tag_format) % dict(version='*')
tag = self.find_branch_tag(commit, upstream_branch, pattern=pattern)
version = self.tag_to_version(tag, upstream_tag_format)
diff --git a/tests/03_test_dch_guess_version.py b/tests/03_test_dch_guess_version.py
index bd4389f..1677b4a 100644
--- a/tests/03_test_dch_guess_version.py
+++ b/tests/03_test_dch_guess_version.py
@@ -98,3 +98,22 @@ class TestGuessVersionFromUpstream(testutils.DebianGitTestRepo):
upstream_branch,
cp)
self.assertEqual(None, guessed)
+
+ def test_guess_mangled_upstream_tag(self):
+ """Guess the new version from the upstream tag using a mangled tag format"""
+ cp = testutils.MockedChangeLog('1.0-1')
+ tagformat = 'upstream/%(version%~%-)s'
+ uversion = '1.1~rc1'
+ upstream_branch = 'upstream'
+
+ self.add_file('doesnot', 'matter')
+ self.repo.create_branch('upstream')
+ tag = self.repo.version_to_tag(tagformat, uversion)
+ self.repo.create_tag(name=tag, msg="Upstream release %s" % uversion,
+ sign=False)
+ self.repo.set_branch("master")
+ guessed = dch.guess_version_from_upstream(self.repo,
+ tagformat,
+ upstream_branch,
+ cp)
+ self.assertEqual('1.1~rc1-1', guessed)