diff options
Diffstat (limited to 'lib/git_python')
-rw-r--r-- | lib/git_python/git.py | 1 | ||||
-rw-r--r-- | lib/git_python/repo.py | 22 |
2 files changed, 19 insertions, 4 deletions
diff --git a/lib/git_python/git.py b/lib/git_python/git.py index ad08bb20..ee256356 100644 --- a/lib/git_python/git.py +++ b/lib/git_python/git.py @@ -26,6 +26,7 @@ class Git(MethodMissingMixin): ``command`` The command to execute """ + print command proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE diff --git a/lib/git_python/repo.py b/lib/git_python/repo.py index f04ba19c..dc9fa729 100644 --- a/lib/git_python/repo.py +++ b/lib/git_python/repo.py @@ -250,13 +250,17 @@ class Repo(object): return Commit.diff(self, commit) @classmethod - def init_bare(self, path, **kwargs): + def init_bare(self, path, mkdir=True, **kwargs): """ Initialize a bare git repository at the given path ``path`` is the full path to the repo (traditionally ends with /<name>.git) + ``mkdir`` + if specified will create the repository directory if it doesn't + already exists. Creates the directory with a mode=0755. + ``kwargs`` is any additional options to the git init command @@ -267,9 +271,19 @@ class Repo(object): Returns ``GitPython.Repo`` (the newly created repo) """ - git = Git(path) - git.init(**kwargs) + split = os.path.split(path) + if split[-1] == '.git' or os.path.split(split[0])[-1] == '.git': + gitpath = path + else: + gitpath = os.path.join(path, '.git') + + if mkdir and not os.path.exists(gitpath): + os.makedirs(gitpath, 0755) + + git = Git(gitpath) + output = git.init(**kwargs) return Repo(path) + create = init_bare def fork_bare(self, path, **kwargs): """ @@ -284,7 +298,7 @@ class Repo(object): Returns ``GitPython.Repo`` (the newly forked repo) """ - options = {'bare': True, 'shared': False} + options = {'bare': True} options.update(kwargs) self.git.clone(self.path, path, **options) return Repo(path) |