# HG changeset patch # User Marcin Kuzminski # Date 2012-02-28 05:08:42 # Node ID 572855f7a39213b7a38a990582a2aa3556115728 # Parent d7f1fe9cb146f3272ed5ea70daf8e999d5806ece reverted git fix as it broke pushing diff --git a/docs/changelog.rst b/docs/changelog.rst --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,7 +20,7 @@ fixes - fixed git protocol issues with repos-groups - fixed git remote repos validator that prevented from cloning remote git repos - fixes #370 ending slashes fixes for repo and groups -- fixes #368 improved git-protocol detection to handle other clients +#- fixes #368 improved git-protocol detection to handle other clients - fixes #366 When Setting Repository Group To Blank Repo Group Wont Be Moved To Root diff --git a/rhodecode/lib/middleware/simplegit.py b/rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py +++ b/rhodecode/lib/middleware/simplegit.py @@ -83,19 +83,22 @@ log = logging.getLogger(__name__) 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 @@ class SimpleGit(BaseVCSController): except: return HTTPInternalServerError()(environ, start_response) + #====================================================================== + # GET ACTION PULL or PUSH + #====================================================================== + action = self.__get_action(environ) #====================================================================== # CHECK ANONYMOUS PERMISSION