From a498bdf1b4a20fef1dea1a0d051899372aa50b73 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Thu, 19 Feb 2009 19:07:32 +0100 Subject: add GitRepository.rev_parse --- gbp/git_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gbp') diff --git a/gbp/git_utils.py b/gbp/git_utils.py index ce4ebed9..193efeb7 100644 --- a/gbp/git_utils.py +++ b/gbp/git_utils.py @@ -58,7 +58,6 @@ class GitRepository(object): out, ret = self.__git_getoutput('tag', [ '-l', tag ]) return [ False, True ][len(out)] - def get_branch(self): """on what branch is the current working copy""" self.__check_path() @@ -132,6 +131,13 @@ class GitRepository(object): raise GitRepositoryError, "can't find tag for %s" % branch return tag[0].strip() + def rev_parse(self, name): + "find the SHA1" + sha, ret = self.__git_getoutput('rev-parse', [ "--verify", name]) + if ret: + raise GitRepositoryError, "can't find SHA1 for %s" % name + return sha[0].strip() + def write_tree(self): """write out the current index, return the SHA1""" tree, ret = self.__git_getoutput('write-tree') -- cgit v1.2.3