Show More
@@ -44,7 +44,7 b' from rhodecode.lib.hooks_daemon import p' | |||||
44 | from rhodecode.lib.middleware import appenlight |
|
44 | from rhodecode.lib.middleware import appenlight | |
45 | from rhodecode.lib.middleware.utils import scm_app |
|
45 | from rhodecode.lib.middleware.utils import scm_app | |
46 | from rhodecode.lib.utils import ( |
|
46 | from rhodecode.lib.utils import ( | |
47 | is_valid_repo, get_rhodecode_realm, get_rhodecode_base_path) |
|
47 | is_valid_repo, get_rhodecode_realm, get_rhodecode_base_path, SLUG_RE) | |
48 | from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool |
|
48 | from rhodecode.lib.utils2 import safe_str, fix_PATH, str2bool | |
49 | from rhodecode.lib.vcs.conf import settings as vcs_settings |
|
49 | from rhodecode.lib.vcs.conf import settings as vcs_settings | |
50 | from rhodecode.lib.vcs.backends import base |
|
50 | from rhodecode.lib.vcs.backends import base | |
@@ -89,6 +89,17 b' class SimpleVCS(object):' | |||||
89 | url_repo_name = None |
|
89 | url_repo_name = None | |
90 | vcs_repo_name = None |
|
90 | vcs_repo_name = None | |
91 |
|
91 | |||
|
92 | # We have to handle requests to shadow repositories different than requests | |||
|
93 | # to normal repositories. Therefore we have to distinguish them. To do this | |||
|
94 | # we use this regex which will match only on URLs pointing to shadow | |||
|
95 | # repositories. | |||
|
96 | shadow_repo_re = re.compile( | |||
|
97 | '(?P<groups>(?:{slug_pat})(?:/{slug_pat})*)' # repo groups | |||
|
98 | '/(?P<target>{slug_pat})' # target repo | |||
|
99 | '/pull-request/(?P<pr_id>\d+)' # pull request | |||
|
100 | '/repository$' # shadow repo | |||
|
101 | .format(slug_pat=SLUG_RE.pattern)) | |||
|
102 | ||||
92 | def __init__(self, application, config, registry): |
|
103 | def __init__(self, application, config, registry): | |
93 | self.registry = registry |
|
104 | self.registry = registry | |
94 | self.application = application |
|
105 | self.application = application | |
@@ -111,15 +122,6 b' class SimpleVCS(object):' | |||||
111 | This will populate the attributes acl_repo_name, url_repo_name, |
|
122 | This will populate the attributes acl_repo_name, url_repo_name, | |
112 | vcs_repo_name and is_shadow_repo on the current instance. |
|
123 | vcs_repo_name and is_shadow_repo on the current instance. | |
113 | """ |
|
124 | """ | |
114 | # TODO: martinb: Move to class or module scope. |
|
|||
115 | from rhodecode.lib.utils import SLUG_RE |
|
|||
116 | pr_regex = re.compile( |
|
|||
117 | '(?P<groups>(?:{slug_pat})(?:/{slug_pat})*)' # repo groups |
|
|||
118 | '/(?P<target>{slug_pat})' # target repo |
|
|||
119 | '/pull-request/(?P<pr_id>\d+)' # pull request |
|
|||
120 | '/repository$' # shadow repo |
|
|||
121 | .format(slug_pat=SLUG_RE.pattern)) |
|
|||
122 |
|
||||
123 | # Get url repo name from environment. |
|
125 | # Get url repo name from environment. | |
124 | self.url_repo_name = self._get_repository_name(environ) |
|
126 | self.url_repo_name = self._get_repository_name(environ) | |
125 |
|
127 | |||
@@ -128,7 +130,11 b' class SimpleVCS(object):' | |||||
128 | # shadow repo. And set acl_repo_name to the pull request target repo |
|
130 | # shadow repo. And set acl_repo_name to the pull request target repo | |
129 | # because we use the target repo for permission checks. Otherwise all |
|
131 | # because we use the target repo for permission checks. Otherwise all | |
130 | # names are equal. |
|
132 | # names are equal. | |
131 |
match = |
|
133 | match = self.shadow_repo_re.match(self.url_repo_name) | |
|
134 | # TODO: martinb: Think about checking the target repo from PR against | |||
|
135 | # the part in the URL. Otherwise we only rely on the PR id in the URL | |||
|
136 | # and the variable parts can be anything. This will lead to 500 errors | |||
|
137 | # from the VCSServer. | |||
132 | if match: |
|
138 | if match: | |
133 | # Get pull request instance. |
|
139 | # Get pull request instance. | |
134 | match_dict = match.groupdict() |
|
140 | match_dict = match.groupdict() |
General Comments 0
You need to be logged in to leave comments.
Login now