Mercurial > kallithea
changeset 2061:9f0fe6777833 beta
merge pull request #32 from codingtony
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 28 Feb 2012 17:44:17 +0200 |
parents | 572855f7a392 |
children | bf8ed0adbc66 |
files | docs/changelog.rst rhodecode/lib/middleware/simplegit.py |
diffstat | 2 files changed, 9 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/changelog.rst Tue Feb 28 07:08:42 2012 +0200 +++ b/docs/changelog.rst Tue Feb 28 17:44:17 2012 +0200 @@ -20,7 +20,7 @@ - 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
--- a/rhodecode/lib/middleware/simplegit.py Tue Feb 28 07:08:42 2012 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Tue Feb 28 17:44:17 2012 +0200 @@ -80,24 +80,20 @@ log = logging.getLogger(__name__) -GIT_PROTO_PAT = re.compile(r'git-upload-pack|git-receive-pack|info\/refs') +GIT_PROTO_PAT = re.compile(r'^/(.+)/(info/refs|git-upload-pack|git-receive-pack)') 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 + path_info = environ['PATH_INFO'] + isgit_path = GIT_PROTO_PAT.match(path_info) + log.debug('is a git path %s pathinfo : %s' % (isgit_path, path_info)) + return isgit_path class SimpleGit(BaseVCSController): def _handle_request(self, environ, start_response): + if not is_git(environ): return self.application(environ, start_response) @@ -222,13 +218,7 @@ """ try: environ['PATH_INFO'] = self._get_by_id(environ['PATH_INFO']) - repo_name = '/'.join(environ['PATH_INFO'].split('/')[1:]) - repo_name = GIT_PROTO_PAT.split(repo_name) - if repo_name: - repo_name = repo_name[0] - - if repo_name.endswith('/'): - repo_name = repo_name.rstrip('/') + repo_name = GIT_PROTO_PAT.match(environ['PATH_INFO']).group(1) except: log.error(traceback.format_exc()) raise @@ -239,8 +229,7 @@ return User.get_by_username(username) def __get_action(self, environ): - """ - Maps git request commands into a pull or push command. + """Maps git request commands into a pull or push command. :param environ: """