@@ -143,59 +143,58 @@ class GitRepository(object):
if git_command in [u'git-receive-pack']:
# updating refs manually after each push.
# Needed for pre-1.7.0.4 git clients using regular HTTP mode.
subprocess.call(u'git --git-dir "%s" '
'update-server-info' % self.content_path,
shell=True)
resp = Response()
resp.content_type = 'application/x-%s-result' % git_command.encode('utf8')
resp.charset = None
resp.app_iter = out
return resp
def __call__(self, environ, start_response):
request = Request(environ)
_path = self._get_fixedpath(request.path_info)
if _path.startswith('info/refs'):
app = self.inforefs
elif [a for a in self.valid_accepts if a in request.accept]:
app = self.backend
try:
resp = app(request, environ)
except exc.HTTPException, e:
resp = e
log.exception(e)
except Exception, e:
resp = exc.HTTPInternalServerError()
return resp(environ, start_response)
class GitDirectory(object):
def __init__(self, repo_root, repo_name, extras):
repo_location = os.path.join(repo_root, repo_name)
if not os.path.isdir(repo_location):
raise OSError(repo_location)
self.content_path = repo_location
self.repo_name = repo_name
self.repo_location = repo_location
self.extras = extras
content_path = self.content_path
app = GitRepository(self.repo_name, content_path, self.extras)
except (AssertionError, OSError):
if os.path.isdir(os.path.join(content_path, '.git')):
app = GitRepository(self.repo_name,
os.path.join(content_path, '.git'),
self.username)
content_path = os.path.join(content_path, '.git')
if os.path.isdir(content_path):
else:
return exc.HTTPNotFound()(environ, start_response)
return app(environ, start_response)
def make_wsgi_app(repo_name, repo_root, extras):
return GitDirectory(repo_root, repo_name, extras)
Status change: