1818from tree import Tree
1919
2020class Repo (object ):
21+ """
22+ Represents a git repository and allows you to query references,
23+ gather commit information, generate diffs, create and clone repositories query
24+ the log.
25+ """
2126 DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
2227
2328 def __init__ (self , path = None ):
@@ -32,6 +37,9 @@ def __init__(self, path=None):
3237 repo = Repo("/Users/mtrier/Development/git-python")
3338 repo = Repo("/Users/mtrier/Development/git-python.git")
3439
40+ Raises
41+ InvalidGitRepositoryError or NoSuchPathError
42+
3543 Returns
3644 ``git.Repo``
3745 """
@@ -110,13 +118,15 @@ def commits(self, start='master', path='', max_count=10, skip=0):
110118 is the branch/commit name (default 'master')
111119
112120 ``path``
113- is an optional path
121+ is an optional path to limit the returned commits to
122+ Commits that do not contain that path will not be returned.
114123
115124 ``max_count``
116125 is the maximum number of commits to return (default 10)
117126
118127 ``skip``
119- is the number of commits to skip (default 0)
128+ is the number of commits to skip (default 0) which will effectively
129+ move your commit-window by the given number.
120130
121131 Returns
122132 ``git.Commit[]``
@@ -126,7 +136,7 @@ def commits(self, start='master', path='', max_count=10, skip=0):
126136
127137 return Commit .find_all (self , start , path , ** options )
128138
129- def commits_between (self , frm , to , path = '' ):
139+ def commits_between (self , frm , to ):
130140 """
131141 The Commits objects that are reachable via ``to`` but not via ``frm``
132142 Commits are returned in chronological order.
@@ -137,9 +147,6 @@ def commits_between(self, frm, to, path = ''):
137147 ``to``
138148 is the branch/commit name of the older item
139149
140- ``path``
141- is an optional path
142-
143150 Returns
144151 ``git.Commit[]``
145152 """
@@ -154,7 +161,8 @@ def commits_since(self, start='master', path='', since='1970-01-01'):
154161 is the branch/commit name (default 'master')
155162
156163 ``path``
157- is an optinal path
164+ is an optinal path to limit the returned commits to.
165+
158166
159167 ``since``
160168 is a string represeting a date/time
@@ -174,10 +182,11 @@ def commit_count(self, start='master', path=''):
174182 is the branch/commit name (default 'master')
175183
176184 ``path``
177- is an optinal path
185+ is an optional path
186+ Commits that do not contain the path will not contribute to the count.
178187
179188 Returns
180- int
189+ `` int``
181190 """
182191 return Commit .count (self , start , path )
183192
@@ -189,25 +198,25 @@ def commit(self, id, path = ''):
189198 is the SHA1 identifier of the commit
190199
191200 ``path``
192- is an optinal path
201+ is an optional path, if set the returned commit must contain the path.
193202
194203 Returns
195- git.Commit
204+ `` git.Commit``
196205 """
197206 options = {'max_count' : 1 }
198207
199208 commits = Commit .find_all (self , id , path , ** options )
200209
201210 if not commits :
202- raise ValueError , ' Invalid identifier %s' % id
211+ raise ValueError , " Invalid identifier %s, or given path '%s' too restrictive" % ( id , path )
203212 return commits [0 ]
204213
205214 def commit_deltas_from (self , other_repo , ref = 'master' , other_ref = 'master' ):
206215 """
207216 Returns a list of commits that is in ``other_repo`` but not in self
208217
209218 Returns
210- `` git.Commit[]``
219+ git.Commit[]
211220 """
212221 repo_refs = self .git .rev_list (ref , '--' ).strip ().splitlines ()
213222 other_repo_refs = other_repo .git .rev_list (other_ref , '--' ).strip ().splitlines ()
@@ -246,7 +255,11 @@ def blob(self, id):
246255
247256 def log (self , commit = 'master' , path = None , ** kwargs ):
248257 """
249- The commit log for a treeish
258+ The Commit for a treeish, and all commits leading to it.
259+
260+ ``kwargs``
261+ keyword arguments specifying flags to be used in git-log command,
262+ i.e.: max_count=1 to limit the amount of commits returned
250263
251264 Returns
252265 ``git.Commit[]``
@@ -270,6 +283,9 @@ def diff(self, a, b, *paths):
270283
271284 ``paths``
272285 is an optional list of file paths on which to restrict the diff
286+
287+ Returns
288+ ``str``
273289 """
274290 return self .git .diff (a , b , '--' , * paths )
275291
@@ -296,7 +312,7 @@ def init_bare(self, path, mkdir=True, **kwargs):
296312 already exists. Creates the directory with a mode=0755.
297313
298314 ``kwargs``
299- is any additional options to the git init command
315+ keyword arguments serving as additional options to the git init command
300316
301317 Examples::
302318
@@ -321,8 +337,8 @@ def fork_bare(self, path, **kwargs):
321337 ``path``
322338 is the full path of the new repo (traditionally ends with /<name>.git)
323339
324- ``options ``
325- is any additional options to the git clone command
340+ ``kwargs ``
341+ keyword arguments to be given to the git clone command
326342
327343 Returns
328344 ``git.Repo`` (the newly forked repo)
@@ -340,7 +356,7 @@ def archive_tar(self, treeish='master', prefix=None):
340356 is the treeish name/id (default 'master')
341357
342358 ``prefix``
343- is the optional prefix
359+ is the optional prefix to prepend to each filename in the archive
344360
345361 Examples::
346362
@@ -351,10 +367,10 @@ def archive_tar(self, treeish='master', prefix=None):
351367 <String containing tar archive for commit a87ff14>
352368
353369 >>> repo.archive_tar('master', 'myproject/')
354- <String containing tar archive and prefixed with 'myproject/'>
370+ <String containing tar bytes archive, whose files are prefixed with 'myproject/'>
355371
356372 Returns
357- str (containing tar archive)
373+ str (containing bytes of tar archive)
358374 """
359375 options = {}
360376 if prefix :
@@ -369,7 +385,7 @@ def archive_tar_gz(self, treeish='master', prefix=None):
369385 is the treeish name/id (default 'master')
370386
371387 ``prefix``
372- is the optional prefix
388+ is the optional prefix to prepend to each filename in the archive
373389
374390 Examples::
375391
@@ -383,7 +399,7 @@ def archive_tar_gz(self, treeish='master', prefix=None):
383399 <String containing tar.gz archive and prefixed with 'myproject/'>
384400
385401 Returns
386- str (containing tar.gz archive)
402+ str (containing the bytes of tar.gz archive)
387403 """
388404 kwargs = {}
389405 if prefix :
@@ -408,16 +424,16 @@ def _set_daemon_export(self, value):
408424 os .unlink (filename )
409425
410426 daemon_export = property (_get_daemon_export , _set_daemon_export ,
411- doc = "git-daemon export of this repository" )
427+ doc = "If True, git-daemon may export this repository" )
412428 del _get_daemon_export
413429 del _set_daemon_export
414430
415431 def _get_alternates (self ):
416432 """
417- The list of alternates for this repo
433+ The list of alternates for this repo from which objects can be retrieved
418434
419435 Returns
420- list[str] ( pathnames of alternates)
436+ list of strings being pathnames of alternates
421437 """
422438 alternates_path = os .path .join (self .path , 'objects' , 'info' , 'alternates' )
423439
@@ -436,8 +452,12 @@ def _set_alternates(self, alts):
436452 Sets the alternates
437453
438454 ``alts``
439- is the Array of String paths representing the alternates
455+ is the array of string paths representing the alternates at which
456+ git should look for objects, i.e. /home/user/repo/.git/objects
440457
458+ Raises
459+ NoSuchPathError
460+
441461 Returns
442462 None
443463 """
@@ -454,17 +474,19 @@ def _set_alternates(self, alts):
454474 finally :
455475 f .close ()
456476
457- alternates = property (_get_alternates , _set_alternates )
477+ alternates = property (_get_alternates , _set_alternates , doc = "Retrieve a list of alternates paths or set a list paths to be used as alternates" )
458478
459479 @property
460480 def is_dirty (self ):
461481 """
462- Return the status of the working directory .
482+ Return the status of the index .
463483
464484 Returns
465- ``True``, if the working directory has any uncommitted changes,
485+ ``True``, if the index has any uncommitted changes,
466486 otherwise ``False``
467487
488+ NOTE
489+ Working tree changes that have not been staged will not be detected !
468490 """
469491 if self .bare :
470492 # Bare repositories with no associated working directory are
0 commit comments