[git-buildpackage] [PATCH] dch: unmangle upstream_tag when guessing upstream version

Guido Günther agx at sigxcpu.org
Mon Jul 10 18:31:00 CEST 2017


On Sat, Jul 08, 2017 at 03:25:32PM +0300, Christos Trochalakis wrote:
> Running `gbp dch` with a mangled upstream tag resulted in a KeyError
> while trying to build a tag pattern.
> ---
> gbp/deb/git.py                     |  2 +-
> tests/03_test_dch_guess_version.py | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+), 1 deletion(-)
> 
> 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)
> -- 

Pushed. Thanks a lot for providing a test case as well!
 -- Guido


More information about the git-buildpackage mailing list