##// END OF EJS Templates
vcs: Use regular expression to recognize requests to shadow repositories.
Martin Bornhold -
r888:6690eec6 default
parent child Browse files
Show More
@@ -19,6 +19,7 b''
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 import gzip
22 import re
22 23 import shutil
23 24 import logging
24 25 import tempfile
@@ -181,16 +182,17 b' class VCSMiddleware(object):'
181 182 url_repo_name = repo_name
182 183 pr_id = None
183 184
184 # TODO: johbo: recognize a pull request based on pattern matching
185 if '/pull-request/' in repo_name:
186 acl_repo_name, other = repo_name.split('/pull-request/')
187 # TODO: johbo: Set shadow repo path
188 basename, repo_segment = acl_repo_name.rsplit('/', 1)
189 pr_id = int(other[0:-len('/repository')])
190 vcs_repo_name = '{basename}/.__shadow_{repo_segment}_pr-{pr_id}'.format(
191 basename=basename,
192 repo_segment=repo_segment,
193 pr_id=pr_id)
185 pr_regex = re.compile(
186 '(?P<base_name>(?:[\w-]+)(?:/[\w-]+)*)/'
187 '(?P<repo_name>[\w-]+)'
188 '/pull-request/(?P<pr_id>\d+)/repository')
189 match = pr_regex.match(repo_name)
190 if match:
191 match_dict = match.groupdict()
192 pr_id = match_dict.get('pr_id')
193 acl_repo_name = '{base_name}/{repo_name}'.format(**match_dict)
194 vcs_repo_name = '{base_name}/.__shadow_{repo_name}_pr-{pr_id}'.format(
195 **match_dict)
194 196
195 197 log.debug('repo_names %s', {
196 198 'acl_repo_name': acl_repo_name,
General Comments 0
You need to be logged in to leave comments. Login now