diff options
author | Paul Sowden <paul@idontsmoke.co.uk> | 2008-11-19 23:27:36 -0800 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-12-15 14:12:04 -0500 |
commit | 9e14356d12226cb140b0e070bd079468b4ab599b (patch) | |
tree | e0520e90acb8af1f0efd62cbdbce7061be702d51 /lib/git/repo.py | |
parent | 5bb812243dd1815651281a54c8191fc8e2bc2d82 (diff) | |
download | gitpython-9e14356d12226cb140b0e070bd079468b4ab599b.tar.gz |
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)
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r-- | lib/git/repo.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py index 09215b1e..47f9c2ce 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -100,13 +100,16 @@ class Repo(object): """ return Tag.find_all(self) - def commits(self, start = 'master', max_count = 10, skip = 0): + def commits(self, start = 'master', path = '', max_count = 10, skip = 0): """ A list of Commit objects representing the history of a given ref/commit ``start`` is the branch/commit name (default 'master') + ``path`` + is an optional path + ``max_count`` is the maximum number of commits to return (default 10) @@ -119,9 +122,9 @@ class Repo(object): options = {'max_count': max_count, 'skip': skip} - return Commit.find_all(self, start, **options) + return Commit.find_all(self, start, path, **options) - def commits_between(self, frm, to): + def commits_between(self, frm, to, path = ''): """ The Commits objects that are reachable via ``to`` but not via ``frm`` Commits are returned in chronological order. @@ -132,12 +135,15 @@ class Repo(object): ``to`` is the branch/commit name of the older item + ``path`` + is an optinal path + Returns ``git.Commit[]`` """ - return Commit.find_all(self, "%s..%s" % (frm, to)).reverse() + return Commit.find_all(self, "%s..%s" % (frm, to), path).reverse() - def commits_since(self, start = 'master', since = '1970-01-01'): + def commits_since(self, start = 'master', path = '', since = '1970-01-01'): """ The Commits objects that are newer than the specified date. Commits are returned in chronological order. @@ -145,6 +151,9 @@ class Repo(object): ``start`` is the branch/commit name (default 'master') + ``path`` + is an optinal path + ``since`` is a string represeting a date/time @@ -153,33 +162,39 @@ class Repo(object): """ options = {'since': since} - return Commit.find_all(self, start, **options) + return Commit.find_all(self, start, path, **options) - def commit_count(self, start = 'master'): + def commit_count(self, start = 'master', path = ''): """ The number of commits reachable by the given branch/commit ``start`` is the branch/commit name (default 'master') + ``path`` + is an optinal path + Returns int """ - return Commit.count(self, start) + return Commit.count(self, start, path) - def commit(self, id): + def commit(self, id, path = ''): """ The Commit object for the specified id ``id`` is the SHA1 identifier of the commit + ``path`` + is an optinal path + Returns git.Commit """ options = {'max_count': 1} - commits = Commit.find_all(self, id, **options) + commits = Commit.find_all(self, id, path, **options) if not commits: raise ValueError, 'Invalid identifier %s' % id |