comparison rhodecode/lib/middleware/simplegit.py @ 2716:4c71667160e5 beta

use os.environ as a fallback for getting special info from hooks, this will allow calling RhodeCode hooks from outside the system eg. via SSH - also verify repo if it's a correct VCS throw 404 error otherwise
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 15 Aug 2012 00:22:53 +0200
parents f0851f37d6be
children aa17c7a1b8a5
comparison
equal deleted inserted replaced
2715:298bac3757a7 2716:4c71667160e5
79 79
80 from rhodecode.lib.utils2 import safe_str 80 from rhodecode.lib.utils2 import safe_str
81 from rhodecode.lib.base import BaseVCSController 81 from rhodecode.lib.base import BaseVCSController
82 from rhodecode.lib.auth import get_container_username 82 from rhodecode.lib.auth import get_container_username
83 from rhodecode.lib.utils import is_valid_repo, make_ui 83 from rhodecode.lib.utils import is_valid_repo, make_ui
84 from rhodecode.lib.compat import json
84 from rhodecode.model.db import User, RhodeCodeUi 85 from rhodecode.model.db import User, RhodeCodeUi
85 86
86 log = logging.getLogger(__name__) 87 log = logging.getLogger(__name__)
87 88
88 89
120 log.debug('Extracted repo name is %s' % repo_name) 121 log.debug('Extracted repo name is %s' % repo_name)
121 except: 122 except:
122 return HTTPInternalServerError()(environ, start_response) 123 return HTTPInternalServerError()(environ, start_response)
123 124
124 # quick check if that dir exists... 125 # quick check if that dir exists...
125 if is_valid_repo(repo_name, self.basepath) is False: 126 if is_valid_repo(repo_name, self.basepath, 'git') is False:
126 return HTTPNotFound()(environ, start_response) 127 return HTTPNotFound()(environ, start_response)
127 128
128 #====================================================================== 129 #======================================================================
129 # GET ACTION PULL or PUSH 130 # GET ACTION PULL or PUSH
130 #====================================================================== 131 #======================================================================
188 'username': username, 189 'username': username,
189 'action': action, 190 'action': action,
190 'repository': repo_name, 191 'repository': repo_name,
191 'scm': 'git', 192 'scm': 'git',
192 } 193 }
193 194 # set the environ variables for this request
195 os.environ['RC_SCM_DATA'] = json.dumps(extras)
194 #=================================================================== 196 #===================================================================
195 # GIT REQUEST HANDLING 197 # GIT REQUEST HANDLING
196 #=================================================================== 198 #===================================================================
197 repo_path = os.path.join(safe_str(self.basepath), safe_str(repo_name)) 199 repo_path = os.path.join(safe_str(self.basepath), safe_str(repo_name))
198 log.debug('Repository path is %s' % repo_path) 200 log.debug('Repository path is %s' % repo_path)