aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-01-19 17:03:38 +0200
committerGuido Günther <agx@sigxcpu.org>2012-01-21 17:45:55 +0100
commitefaa8a2578e0c3ba99569be0dfef62ffc5a651ad (patch)
treef95bcdd7aa924fe59e01bca32373ba7b8d5d6afa /gbp
parentccef796d48f81c841f9cf188bd97d6f76910033c (diff)
deb: make find_version() return sha1 of a commit
Change find_version() so that it always returns sha1 of a commit object. That is, annotated tags are dereferenced to a commit object. Previously find_commit returned the sha1 of the tag object.
Diffstat (limited to 'gbp')
-rw-r--r--gbp/deb/git.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/gbp/deb/git.py b/gbp/deb/git.py
index c6dc10f5..8e2561ac 100644
--- a/gbp/deb/git.py
+++ b/gbp/deb/git.py
@@ -24,7 +24,9 @@ class DebianGitRepository(GitRepository):
def find_version(self, format, version):
"""
- Check if a certain version is stored in this repo and return it's SHA1.
+ Check if a certain version is stored in this repo and return the SHA1
+ of the related commit. That is, an annotated tag is dereferenced to the
+ commit object it points to.
For legacy tags don't only check the tag itself but also the commit
message, since the former wasn't injective until release 0.5.5. You
@@ -33,19 +35,21 @@ class DebianGitRepository(GitRepository):
@param format: tag pattern
@param version: debian version number
- @return: sha1 of the version tag
+ @return: sha1 of the commit the tag references to
"""
tag = self.version_to_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)
+ # dereference to a commit object
+ return self.rev_parse("%s^0" % 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)
+ # dereference to a commit object
+ return self.rev_parse("%s^0" % legacy_tag)
elif line.startswith('---'): # GPG signature start
return None
return None