diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-03-14 19:57:53 +0100 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-03-14 19:57:53 +0100 |
commit | 5f0802e2fba0fae6dae391829f4cfc9a6cad1d0e (patch) | |
tree | 8c9fd07f25760f6731d9eace080e4ca30d4b7099 /gbp | |
parent | 410adc82eb7717b94ef5336fc5c61033679e48b3 (diff) |
add commit() and show()
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/git_utils.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gbp/git_utils.py b/gbp/git_utils.py index 90802cc3..72abdd95 100644 --- a/gbp/git_utils.py +++ b/gbp/git_utils.py @@ -27,7 +27,6 @@ class GitRepository(object): if os.getcwd() != self.path: raise GitRepositoryError - def __git_getoutput(self, command, args=[]): """exec a git command and return the output""" output = [] @@ -67,7 +66,7 @@ class GitRepository(object): for line in self.__git_getoutput('branch', [ '--no-color' ])[0]: if line.startswith('*'): return line.split(' ', 1)[1].strip() - + def is_clean(self): """does the repository contain any uncommitted modifications""" @@ -93,6 +92,22 @@ class GitRepository(object): else: return [] + def commits(self, start, end, paths, options): + """get commits from start to end touching pathds""" + commits, ret = self.__git_getoutput('log', ['--pretty=format:%H', + options, '%s..%s' % (start, end), + '--', paths]) + if ret: + raise GitRepositoryError, "Error gettint commits %s..%s on %s" % (start, end, paths) + return [ commit.strip() for commit in commits ] + + def show(self, id): + """git-show id""" + commit, ret = self.__git_getoutput('show', [ id ]) + if ret: + raise GitRepositoryError, "can't get %s" % id + return commit + def build_tag(format, version): """Generate a tag from a given format and a version""" |