summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-12-28 09:31:51 +0100
committerGuido Günther <agx@sigxcpu.org>2011-12-28 10:00:34 +0100
commit6850005ea0652a314a154e978f3dbe793801d57c (patch)
treefb7034caf04ceafc1c301fd8d15e5a1c43f1eff9
parent95f46f09eab66acd7d29ef55b855378ab87c56a8 (diff)
Move _build_legacty_tag from GitRepository to to DebianGitRepository
and add doctest. Git-Dch: Ignore
-rw-r--r--gbp/deb/git.py13
-rw-r--r--gbp/git/repository.py7
2 files changed, 13 insertions, 7 deletions
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index f8cefedf..5890df22 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -51,6 +51,19 @@ class DebianGitRepository(GitRepository):
return None
@staticmethod
+ def _build_legacy_tag(format, version):
+ """
+ Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~'
+
+ >>> DebianGitRepository._build_legacy_tag('upstream/%(version)s', '1:2.0~3')
+ 'upstream/2.0.3'
+ """
+ if ':' in version: # strip of any epochs
+ version = version.split(':', 1)[1]
+ version = version.replace('~', '.')
+ return format % dict(version=version)
+
+ @staticmethod
def version_to_tag(format, version):
"""Generate a tag from a given format and a version
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 58d67bec..0cd9c0f1 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -423,13 +423,6 @@ class GitRepository(object):
out, ret = self.__git_getoutput('tag', [ '-l', tag ])
return [ False, True ][len(out)]
- def _build_legacy_tag(self, format, version):
- """legacy version numbering"""
- if ':' in version: # strip of any epochs
- version = version.split(':', 1)[1]
- version = version.replace('~', '.')
- return format % dict(version=version)
-
def find_tag(self, commit, pattern=None):
"""
Find the closest tag to a given commit