summaryrefslogtreecommitdiff
path: root/gbp/git
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-07-03 10:06:54 +0300
committerGuido Günther <agx@sigxcpu.org>2012-07-03 21:46:26 +0200
commit4d56ab643100776171a66bff9686ff7f676ad1c5 (patch)
tree380210d6871b786222c193ea0c75ce629ba4438b /gbp/git
parent2c668bfe24e01697b7cdba0b621f1a1fcd99e093 (diff)
GitRepository/rev_parse: add new argument 'short'
Adds a new argument to get abbreviated SHA1. Also, modifies rev_parse() to use GitArgs class. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/git')
-rw-r--r--gbp/git/repository.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index d4f9460..5d33fc7 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -602,17 +602,21 @@ class GitRepository(object):
# an empty repo has no branches:
return False if self.branch else True
- def rev_parse(self, name):
+ def rev_parse(self, name, short=None):
"""
Find the SHA1 of a given name
@param name: the name to look for
@type name: C{str}
+ @param short: try to abbreviate SHA1 to given length
+ @type short: C{int}
@return: the name's sha1
@rtype: C{str}
"""
- args = [ "--quiet", "--verify", name ]
- sha, ret = self._git_getoutput('rev-parse', args)
+ args = GitArgs("--quiet", "--verify")
+ args.add_cond(short, '--short=%s' % short)
+ args.add(name)
+ sha, ret = self._git_getoutput('rev-parse', args.args)
if ret:
raise GitRepositoryError("revision '%s' not found" % name)
return sha[0].strip()