summaryrefslogtreecommitdiff
path: root/lib/git_python
diff options
context:
space:
mode:
authorMichael Trier <mtrier@gmail.com>2008-05-18 10:55:31 -0400
committerMichael Trier <mtrier@gmail.com>2008-05-18 10:55:31 -0400
commit0651f0964ba5a33257ebbda1e92c7a1649a4a058 (patch)
treed1565ced15d3ad46e9adf9d88e7622c76cbe6453 /lib/git_python
parent062aafa396866d4dfe8f3fd2f32d46fa7c01b6dd (diff)
downloadgitpython-0651f0964ba5a33257ebbda1e92c7a1649a4a058.tar.gz
lots of little fixes. Corrected problem with creating bare repo. Added Repo.create alias.
Diffstat (limited to 'lib/git_python')
-rw-r--r--lib/git_python/git.py1
-rw-r--r--lib/git_python/repo.py22
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)