Documentation for the new clone method.

Even though I am aware that the comment lines in pygit2/__init__.py are longer than 79 characters, there's a reason for that.
If I break them, they'll show poorly in the documentation, and in my opinion better docs trump the 80 char requirement. If you think it's still better to have less than 80 characters in the comments, I'll gladly resubmit the changes at the expense of the documentation.
This commit is contained in:
Bernardo Heynemann 2013-05-16 10:25:47 -03:00
parent 57ea19e905
commit a377b32b60
2 changed files with 25 additions and 12 deletions

View File

@ -20,6 +20,17 @@ Functions
>>> repo = init_repository('test') # Creates a non-bare repository
>>> repo = init_repository('test', bare=True) # Creates a bare repository
.. autofunction:: pygit2.clone_repository
Example::
>>> from pygit2 import clone_repository
>>> repo_url = 'git://github.com/libgit2/pygit2.git'
>>> repo_path = '/path/to/create/repository'
>>> repo = clone_repository(repo_url, repo_path) # Clones a non-bare repository
>>> repo = clone_repository(repo_url, repo_path, bare=True) # Clones a bare repository
.. autofunction:: pygit2.discover_repository

View File

@ -56,18 +56,20 @@ def clone_repository(
"""
Clones a new Git repository from *url* in the given *path*.
Parameters:
* 'bare' indicates whether a bare git repository should be created.
* 'remote_name' is the name given to the "origin" remote.
The default is "origin".
* 'push_url' is a URL to be used for pushing.
None means use the fetch url.
* 'fetch_spec' is the fetch specification to be used for fetching.
None results in the same behavior as GIT_REMOTE_DEFAULT_FETCH.
* 'push_spec' is the fetch specification to be used for pushing.
None means use the same spec as for 'fetch_spec'.
* 'checkout_branch' gives the name of the branch to checkout.
None means use the remote's HEAD
* **bare** indicates whether a bare git repository should be created.
* **remote_name** is the name given to the "origin" remote. The default is "origin".
* **push_url** is a URL to be used for pushing. None means use the *url* parameter.
* **fetch_spec** defines the the default fetch spec. None results in the same behavior as *GIT_REMOTE_DEFAULT_FETCH*.
* **push_spec** is the fetch specification to be used for pushing. None means use the same spec as for *fetch_spec*.
* **checkout_branch** gives the name of the branch to checkout. None means use the remote's *HEAD*.
Returns a Repository class pointing to the newly cloned repository.
If you wish to use the repo, you need to do a checkout for one of the available branches, like this:
>>> repo = repo.clone_repository("url", "path")
>>> repo.checkout(branch) # i.e.: refs/heads/master
"""
_pygit2.clone_repository(