From 9e14356d12226cb140b0e070bd079468b4ab599b Mon Sep 17 00:00:00 2001 From: Paul Sowden Date: Wed, 19 Nov 2008 23:27:36 -0800 Subject: add a path parameter to most commit methods The path parameter allows you to specify a path to constrain queries by. This changes potentially breaks backwards compatibility for the Repo.commits and Repo.commits_since methods as it moves the positional arguments. (cherry picked from commit cc8a20e78da4864060bd0c9279633009bc10d871) --- lib/git/commit.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/git/commit.py') diff --git a/lib/git/commit.py b/lib/git/commit.py index c50d9d2d..c9e2ab59 100644 --- a/lib/git/commit.py +++ b/lib/git/commit.py @@ -82,7 +82,7 @@ class Commit(LazyMixin): return self.id[0:7] @classmethod - def count(cls, repo, ref): + def count(cls, repo, ref, path=''): """ Count the number of commits reachable from this ref @@ -92,13 +92,16 @@ class Commit(LazyMixin): ``ref`` is the ref from which to begin (SHA1 or name) + ``path`` + is an optinal path + Returns int """ - return len(repo.git.rev_list(ref, '--').strip().splitlines()) + return len(repo.git.rev_list(ref, '--', path).strip().splitlines()) @classmethod - def find_all(cls, repo, ref, **kwargs): + def find_all(cls, repo, ref, path='', **kwargs): """ Find all commits matching the given criteria. ``repo`` @@ -107,6 +110,9 @@ class Commit(LazyMixin): ``ref`` is the ref from which to begin (SHA1 or name) + ``path`` + is an optinal path + ``options`` is a Hash of optional arguments to git where ``max_count`` is the maximum number of commits to fetch @@ -118,7 +124,7 @@ class Commit(LazyMixin): options = {'pretty': 'raw'} options.update(kwargs) - output = repo.git.rev_list(ref, '--', **options) + output = repo.git.rev_list(ref, '--', path, **options) return cls.list_from_string(repo, output) @classmethod -- cgit v1.2.1