summaryrefslogtreecommitdiff
path: root/gbp
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
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')
-rw-r--r--gbp/deb/git.py22
-rw-r--r--gbp/scripts/dch.py16
2 files changed, 28 insertions, 10 deletions
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):
"""
diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py
index f6bcfb1..86c0547 100644
--- a/gbp/scripts/dch.py
+++ b/gbp/scripts/dch.py
@@ -105,18 +105,14 @@ def guess_version_from_upstream(repo, upstream_tag_format, cp):
"""
Guess the version based on the latest version on the upstream branch
"""
- pattern = upstream_tag_format % dict(version='*')
try:
- tag = repo.find_tag('HEAD', pattern=pattern)
- version = repo.tag_to_version(tag, upstream_tag_format)
- if version:
- gbp.log.debug("Found upstream version %s." % version)
- if cp.has_epoch():
- version = "%s:%s" % (cp.epoch, version)
- if compare_versions(version, cp.version) > 0:
- return "%s-1" % version
+ version = repo.debian_version_from_upstream(upstream_tag_format,
+ epoch=cp.epoch)
+ gbp.log.debug("Found upstream version %s." % version)
+ if compare_versions(version, cp.version) > 0:
+ return version
except GitRepositoryError:
- gbp.log.debug("No tag found matching pattern %s." % pattern)
+ gbp.log.debug("No upstream tag found")
return None