aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/git/repository.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-12-27 18:09:11 +0100
committerGuido Günther <agx@sigxcpu.org>2011-12-27 19:13:57 +0100
commitf9ca26405c53a6ad829e1bcf4f60c5a6bb4ae4d9 (patch)
tree79113c3ae290d08f9b322ca4feb67e7bcc59fb23 /gbp/git/repository.py
parent6fc0ec045b5cb4ad01a7583481d83a8552cd76a7 (diff)
GitRepository: Add num option to git_commits
to limit number of returned commits and fix path option to also accept a list of paths instead of a string.
Diffstat (limited to 'gbp/git/repository.py')
-rw-r--r--gbp/git/repository.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 7ad19506..aca9cdb9 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -879,15 +879,20 @@ class GitRepository(object):
#{ Commit Information
- def get_commits(self, since=None, until=None, paths=None, options=None,
- first_parent=False):
+ def get_commits(self, since=None, until=None, paths=None, num=0,
+ first_parent=False, options=None):
"""
Get commits from since to until touching paths
@param since: commit to start from
+ @type since: C{str}
@param until: last commit to get
+ @type until: C{str}
@param paths: only list commits touching paths
- @param options: list of options passed to git log
+ @type paths: C{list} of C{str}
+ @param num: maximum number of commits to fetch
+ @type num: C{int}
+ @param options: list of additional options passed to git log
@type options: C{list} of C{str}ings
@param first_parent: only follow first parent when seeing a
merge commit
@@ -899,6 +904,9 @@ class GitRepository(object):
if options:
args += options
+ if num:
+ args += [ '-%d' % num ]
+
if first_parent:
args += [ "--first-parent" ]
@@ -906,7 +914,9 @@ class GitRepository(object):
args += ['%s..%s' % (since, until)]
if paths:
- args += [ "--", paths ]
+ if isinstance(paths, basestring):
+ paths = [ paths ]
+ args += [ "--" ] + paths
commits, ret = self.__git_getoutput('log', args)
if ret: