aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/deb/git.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-03-27 16:58:47 +0100
committerGuido Günther <agx@sigxcpu.org>2013-03-27 17:07:16 +0100
commit59254996d740b8b8a0db306a7e04950a5f4e51b8 (patch)
treebacd18904064e1dd3c30bf577d979eed831df64c /gbp/deb/git.py
parent3b873f75ef32c500e69da22dcfc73155414bb6d0 (diff)
Split out building a debian version from an upstream commit
based on a patch by Daniel Dehennin Needed for #672954, #646684, #669171
Diffstat (limited to 'gbp/deb/git.py')
-rw-r--r--gbp/deb/git.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index c9004ef8..c7b6e776 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):
"""