From 59254996d740b8b8a0db306a7e04950a5f4e51b8 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Wed, 27 Mar 2013 16:58:47 +0100 Subject: Split out building a debian version from an upstream commit based on a patch by Daniel Dehennin Needed for #672954, #646684, #669171 --- gbp/deb/git.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gbp/deb') diff --git a/gbp/deb/git.py b/gbp/deb/git.py index c9004ef..c7b6e77 100644 --- a/gbp/deb/git.py +++ b/gbp/deb/git.py @@ -62,6 +62,28 @@ class DebianGitRepository(GitRepository): return None return None + def debian_version_from_upstream(self, upstream_tag_format, commit='HEAD', + epoch=None): + """ + Build the Debian version that a package based on upstream commit + I{commit} would carry taking into account a possible epoch. + + @param upstream_tag_format; the tag format on the upstream branch + @type upstream_tag_format; C{str} + @param commit: the commit to search for the latest upstream version + @param epoch: an epoch to use + @returns: a new debian version + @raises: L{GitRepositoryError} if no upstream tag was found + """ + pattern = upstream_tag_format % dict(version='*') + tag = self.find_tag(commit, pattern=pattern) + version = self.tag_to_version(tag, upstream_tag_format) + + version += "-1" + if epoch: + version = "%s:%s" % (epoch, version) + return version + @staticmethod def _build_legacy_tag(format, version): """ -- cgit v1.2.3