Mercurial > kallithea
diff rhodecode/lib/middleware/simplegit.py @ 2060:572855f7a392 beta
reverted git fix as it broke pushing
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 28 Feb 2012 07:08:42 +0200 |
parents | fb51a6fc10ae |
children | 9f0fe6777833 |
line wrap: on
line diff
--- a/rhodecode/lib/middleware/simplegit.py Tue Feb 28 07:05:03 2012 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Tue Feb 28 07:08:42 2012 +0200 @@ -83,19 +83,22 @@ GIT_PROTO_PAT = re.compile(r'git-upload-pack|git-receive-pack|info\/refs') -def is_git(action): - return action in ['pull','push'] +def is_git(environ): + """Returns True if request's target is git server. + ``HTTP_USER_AGENT`` would then have git client version given. + + :param environ: + """ + http_user_agent = environ.get('HTTP_USER_AGENT') + if http_user_agent and http_user_agent.startswith('git'): + return True + return False class SimpleGit(BaseVCSController): def _handle_request(self, environ, start_response): - #====================================================================== - # GET ACTION PULL or PUSH - #====================================================================== - action = self.__get_action(environ) - - if not is_git(action): + if not is_git(environ): return self.application(environ, start_response) proxy_key = 'HTTP_X_REAL_IP' @@ -114,6 +117,10 @@ except: return HTTPInternalServerError()(environ, start_response) + #====================================================================== + # GET ACTION PULL or PUSH + #====================================================================== + action = self.__get_action(environ) #====================================================================== # CHECK ANONYMOUS PERMISSION