summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-10-27 20:57:16 +0200
committerGuido Günther <agx@sigxcpu.org>2011-10-27 22:08:00 +0200
commit1a590241a7b95f13784d735a2e6d34bde83ed31c (patch)
tree5d36f7d98d288182d8a4457a4bda9cee8e362f38 /gbp
parentc4f9f23dace4b3ea87955f9ebe093f302b75f810 (diff)
GitRepository: Don't try to access .git/ in bare repos
Diffstat (limited to 'gbp')
-rw-r--r--gbp/git.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/gbp/git.py b/gbp/git.py
index 01cb060..74ce711 100644
--- a/gbp/git.py
+++ b/gbp/git.py
@@ -95,6 +95,7 @@ class GitRepository(object):
raise GitRepositoryError(
"Failed to get repository state at '%s'" % self.path)
self._bare = False if out[0].strip() != 'true' else True
+ self._git_dir = '' if self._bare else '.git'
def __init__(self, path):
self._path = os.path.abspath(path)
@@ -195,7 +196,7 @@ class GitRepository(object):
@property
def base_dir(self):
"""Get the base of the repository"""
- return os.path.join(self.path, '.git')
+ return os.path.join(self.path, self._git_dir)
@property
def bare(self):
@@ -851,7 +852,7 @@ class GitRepository(object):
@type committer: C{dict} with keys I{name}, I{email}, I{date}
"""
- git_index_file = os.path.join(self.path, '.git', 'gbp_index')
+ git_index_file = os.path.join(self.path, self._git_dir, 'gbp_index')
try:
os.unlink(git_index_file)
except OSError:
@@ -1138,13 +1139,19 @@ class GitRepository(object):
"""
abspath = os.path.abspath(path)
- args = [ '--bare' ] if bare else []
+ if bare:
+ args = [ '--bare' ]
+ git_dir = ''
+ else:
+ args = []
+ git_dir = '.git'
+
try:
if not os.path.exists(abspath):
os.makedirs(abspath)
GitCommand("init", args, cwd=abspath)()
if description:
- with file(os.path.join(abspath, ".git", "description"), 'w') as f:
+ with file(os.path.join(abspath, git_dir, "description"), 'w') as f:
description += '\n' if description[-1] != '\n' else ''
f.write(description)
return klass(abspath)