add find_tag(branch)
authorGuido Guenther <agx@sigxcpu.org>
Mon, 22 Sep 2008 17:54:00 +0000 (19:54 +0200)
committerGuido Guenther <agx@sigxcpu.org>
Mon, 22 Sep 2008 18:07:08 +0000 (20:07 +0200)
gbp/git_utils.py

index 670d9903999df16a161f6161fa386410aa0980f9..9885fc9c4f1d490943a865742f5b35f28ff12ffc 100644 (file)
@@ -111,6 +111,13 @@ class GitRepository(object):
         for line in commit:
             yield line
 
+    def find_tag(self, branch):
+        "find the closest tag to a branch's head"
+        tag, ret = self.__git_getoutput('describe', [ "--abbrev=0", branch ])
+        if ret:
+            raise GitRepositoryError, "can't find tag for %s" % branch
+        return tag[0].strip()
+
     def write_tree(self):
         """write out the current index, return the SHA1"""
         tree, ret = self.__git_getoutput('write-tree')