diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-01-12 15:23:05 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-01-21 17:38:27 +0100 |
commit | ccef796d48f81c841f9cf188bd97d6f76910033c (patch) | |
tree | 7bf9e0ed72e0bf79a9660549221c383ed42c129b /gbp/git | |
parent | b05072150c7cdcadc8d797f33d10e3403996ff54 (diff) |
GitRepository: add get_obj_type()
get_obj_type() returns the type of a git repository object.
Diffstat (limited to 'gbp/git')
-rw-r--r-- | gbp/git/repository.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 2fcc12cc..024a3775 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -618,6 +618,20 @@ class GitRepository(object): if ret: raise GitRepositoryError("Can't write out current index") return tree[0].strip() + + def get_obj_type(self, obj): + """ + Get type of a git repository object + + @param obj: repository object + @type obj: C{str} + @return: type of the repository object + @rtype: C{str} + """ + out, ret = self.__git_getoutput('cat-file', args=['-t', obj]) + if ret: + raise GitRepositoryError("Not a Git repository object: '%s'" % obj) + return out[0].strip() #} def get_config(self, name): |