From 00c5497f190172765cc7a53ff9d8852a26b91676 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 15 Oct 2009 16:52:20 +0200 Subject: repo: made init and clone methods less specific, previously they wanted to do it 'barely' only. New method names closely follow the default git command names --- lib/git/repo.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'lib/git/repo.py') diff --git a/lib/git/repo.py b/lib/git/repo.py index cfa73c43..39b1cb50 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -408,52 +408,52 @@ class Repo(object): return blames @classmethod - def init_bare(self, path, mkdir=True, **kwargs): + def init(cls, path=None, mkdir=True, **kwargs): """ - Initialize a bare git repository at the given path + Initialize a git repository at the given path if specified ``path`` is the full path to the repo (traditionally ends with /.git) + or None in which case the repository will be created in the current + working directory ``mkdir`` if specified will create the repository directory if it doesn't - already exists. Creates the directory with a mode=0755. + already exists. Creates the directory with a mode=0755. + Only effective if a path is explicitly given ``kwargs`` - keyword arguments serving as additional options to the git init command + keyword arguments serving as additional options to the git-init command Examples:: - git.Repo.init_bare('/var/git/myrepo.git') + git.Repo.init('/var/git/myrepo.git',bare=True) Returns ``git.Repo`` (the newly created repo) """ - if mkdir and not os.path.exists(path): + if mkdir and path and not os.path.exists(path): os.makedirs(path, 0755) git = Git(path) - output = git.init('--bare', **kwargs) + output = git.init(path, **kwargs) return Repo(path) - create = init_bare - def fork_bare(self, path, **kwargs): + def clone(self, path, **kwargs): """ - Fork a bare git repository from this repo + Create a clone from this repository. ``path`` is the full path of the new repo (traditionally ends with /.git) ``kwargs`` - keyword arguments to be given to the git clone command + keyword arguments to be given to the git-clone command Returns - ``git.Repo`` (the newly forked repo) + ``git.Repo`` (the newly cloned repo) """ - options = {'bare': True} - options.update(kwargs) - self.git.clone(self.path, path, **options) + self.git.clone(self.path, path, **kwargs) return Repo(path) def archive_tar(self, treeish='master', prefix=None): -- cgit v1.2.1