Show More
@@ -121,6 +121,7 b' class SimpleGit(BaseVCSController):' | |||||
121 | #====================================================================== |
|
121 | #====================================================================== | |
122 | # CHECK ANONYMOUS PERMISSION |
|
122 | # CHECK ANONYMOUS PERMISSION | |
123 | #====================================================================== |
|
123 | #====================================================================== | |
|
124 | ||||
124 | if action in ['pull', 'push']: |
|
125 | if action in ['pull', 'push']: | |
125 | anonymous_user = self.__get_user('default') |
|
126 | anonymous_user = self.__get_user('default') | |
126 | username = anonymous_user.username |
|
127 | username = anonymous_user.username | |
@@ -169,15 +170,13 b' class SimpleGit(BaseVCSController):' | |||||
169 | start_response) |
|
170 | start_response) | |
170 |
|
171 | |||
171 | #check permissions for this repository |
|
172 | #check permissions for this repository | |
172 | perm = self._check_permission(action, user, |
|
173 | perm = self._check_permission(action, user, repo_name) | |
173 | repo_name) |
|
|||
174 | if perm is not True: |
|
174 | if perm is not True: | |
175 | return HTTPForbidden()(environ, start_response) |
|
175 | return HTTPForbidden()(environ, start_response) | |
176 |
|
176 | |||
177 | #=================================================================== |
|
177 | #=================================================================== | |
178 | # GIT REQUEST HANDLING |
|
178 | # GIT REQUEST HANDLING | |
179 | #=================================================================== |
|
179 | #=================================================================== | |
180 |
|
||||
181 | repo_path = safe_str(os.path.join(self.basepath, repo_name)) |
|
180 | repo_path = safe_str(os.path.join(self.basepath, repo_name)) | |
182 | log.debug('Repository path is %s' % repo_path) |
|
181 | log.debug('Repository path is %s' % repo_path) | |
183 |
|
182 | |||
@@ -203,7 +202,6 b' class SimpleGit(BaseVCSController):' | |||||
203 | :param repo_name: name of the repository |
|
202 | :param repo_name: name of the repository | |
204 | :param repo_path: full path to the repository |
|
203 | :param repo_path: full path to the repository | |
205 | """ |
|
204 | """ | |
206 |
|
||||
207 | _d = {'/' + repo_name: Repo(repo_path)} |
|
205 | _d = {'/' + repo_name: Repo(repo_path)} | |
208 | backend = dulserver.DictBackend(_d) |
|
206 | backend = dulserver.DictBackend(_d) | |
209 | gitserve = HTTPGitApplication(backend) |
|
207 | gitserve = HTTPGitApplication(backend) | |
@@ -229,19 +227,24 b' class SimpleGit(BaseVCSController):' | |||||
229 | return User.get_by_username(username) |
|
227 | return User.get_by_username(username) | |
230 |
|
228 | |||
231 | def __get_action(self, environ): |
|
229 | def __get_action(self, environ): | |
232 | """Maps git request commands into a pull or push command. |
|
230 | """ | |
|
231 | Maps git request commands into a pull or push command. | |||
233 |
|
232 | |||
234 | :param environ: |
|
233 | :param environ: | |
235 | """ |
|
234 | """ | |
236 | service = environ['QUERY_STRING'].split('=') |
|
235 | service = environ['QUERY_STRING'].split('=') | |
|
236 | ||||
237 | if len(service) > 1: |
|
237 | if len(service) > 1: | |
238 | service_cmd = service[1] |
|
238 | service_cmd = service[1] | |
239 | mapping = { |
|
239 | mapping = { | |
240 | 'git-receive-pack': 'push', |
|
240 | 'git-receive-pack': 'push', | |
241 | 'git-upload-pack': 'pull', |
|
241 | 'git-upload-pack': 'pull', | |
242 | } |
|
242 | } | |
243 |
|
243 | op = mapping[service_cmd] | ||
244 | return mapping.get(service_cmd, |
|
244 | self._git_stored_op = op | |
245 | service_cmd if service_cmd else 'other') |
|
245 | return op | |
246 | else: |
|
246 | else: | |
247 | return 'other' |
|
247 | # try to fallback to stored variable as we don't know if the last | |
|
248 | # operation is pull/push | |||
|
249 | op = getattr(self, '_git_stored_op', 'pull') | |||
|
250 | return op |
General Comments 0
You need to be logged in to leave comments.
Login now