summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2010-08-10 17:47:24 +0200
committerGuido Günther <agx@sigxcpu.org>2010-08-10 18:51:23 +0200
commit55fdbc67064a4f236b6d1e3ebc885f40c2c1fc44 (patch)
treecb16fd396deebab4c865703515d99b2219e9f66e
parent3c6bbd0f4992f8da91693494f1a8980a4152e564 (diff)
Check for legacy tags where necessary.
-rw-r--r--gbp/git.py37
-rwxr-xr-xgit-dch7
-rwxr-xr-xgit-import-dsc10
3 files changed, 47 insertions, 7 deletions
diff --git a/gbp/git.py b/gbp/git.py
index eec7d2ba..b162bc0d 100644
--- a/gbp/git.py
+++ b/gbp/git.py
@@ -93,6 +93,43 @@ 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_version(self, format, version):
+ """
+ Check if a certain version is stored in this repo. Return it's SHA1 in
+ this case. For legacy tags Don't check only the tag but also the
+ message, since the former wasn't injective until recently.
+ You only need to use this funciton if you also need to check for legacy
+ tags.
+
+ @param pattern: tag pattern
+ @param version: debian version number
+ @return: sha1 of the version tag
+ """
+ tag = build_tag(format, version)
+ legacy_tag = self._build_legacy_tag(format, version)
+ if self.has_tag(tag): # new tags are injective
+ return self.rev_parse(tag)
+ elif self.has_tag(legacy_tag):
+ out, ret = self.__git_getoutput('cat-file', args=['-p', legacy_tag])
+ if ret:
+ return None
+ for line in out:
+ if line.endswith(" %s\n" % version):
+ return self.rev_parse(legacy_tag)
+ elif line.startswith('---'): # GPG signature start
+ return None
+ return None
+
+
def remove_tag(self, tag):
"""remove a tag 'tag'"""
self.__check_path()
diff --git a/git-dch b/git-dch
index 6401cfda..debb974f 100755
--- a/git-dch
+++ b/git-dch
@@ -302,8 +302,7 @@ def guess_snapshot_commit(cp, repo, options):
# If the current topmost changelog entry has already been tagged rely on
# the version information only. The upper level relies then on the version
# info anyway:
- tag = build_tag(options.debian_tag, cp['Version'])
- if repo.has_tag(tag):
+ if repo.find_version(options.debian_tag, cp['Version']):
return None
# If we didn't find a snapshot header we look at the point the changelog
# was last touched.
@@ -415,7 +414,9 @@ def main(argv):
else:
print "Couldn't find snapshot header, using version info"
if not since:
- since = build_tag(options.debian_tag, cp['Version'])
+ since = repo.find_version(options.debian_tag, cp['Version'])
+ if not since:
+ raise GbpError, "Version %s not found" % cp['Version']
if args:
print "Only looking for changes on '%s'" % " ".join(args)
diff --git a/git-import-dsc b/git-import-dsc
index 3914df0c..8def4ec2 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -230,11 +230,13 @@ def main(argv):
format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
tag = build_tag(format[0], src.upstream_version)
msg = "%s version %s" % (format[1], src.upstream_version)
- if repo.has_tag(tag) and options.ignore_same_version:
- print "Tag %s already there" % tag
- raise SkipImport
- if not repo.has_tag(tag):
+ if options.ignore_same_version:
+ if repo.find_version(options.debian_tag, src.version):
+ print "Version %s already imported." % src.version
+ raise SkipImport
+
+ if not repo.find_version(format[0], src.upstream_version):
print "tag %s not found, importing %s tarball" % (tag, format[1])
if is_empty:
branch = None