##// END OF EJS Templates
fix(vcs-operations): fixed problems with locked repos and with branch permissions reporting, previously it shown error 500 when those cases were handled
super-admin -
r5541:8026ecb9 default
parent child Browse files
Show More
@@ -17,6 +17,7 b''
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 19 import logging
20
20 21 import rhodecode
21 22 import collections
22 23
@@ -66,12 +66,12 b' class Hooks(object):'
66 66 result = hook(extras)
67 67 if result is None:
68 68 raise Exception(f'Failed to obtain hook result from func: {hook}')
69 except HTTPBranchProtected as handled_error:
69 except HTTPBranchProtected as error:
70 70 # Those special cases don't need error reporting. It's a case of
71 71 # locked repo or protected branch
72 72 result = AttributeDict({
73 'status': handled_error.code,
74 'output': handled_error.explanation
73 'status': error.code,
74 'output': error.explanation
75 75 })
76 76 except (HTTPLockedRC, Exception) as error:
77 77 # locked needs different handling since we need to also
@@ -142,6 +142,8 b' def pre_push(extras):'
142 142 if extras.commit_ids and extras.check_branch_perms:
143 143 auth_user = user.AuthUser()
144 144 repo = Repository.get_by_repo_name(extras.repository)
145 if not repo:
146 raise ValueError(f'Repo for {extras.repository} not found')
145 147 affected_branches = []
146 148 if repo.repo_type == 'hg':
147 149 for entry in extras.commit_ids:
@@ -293,7 +293,7 b' class SimpleVCS(object):'
293 293 def compute_perm_vcs(
294 294 cache_name, plugin_id, action, user_id, repo_name, ip_addr):
295 295
296 log.debug('auth: calculating permission access now...')
296 log.debug('auth: calculating permission access now for vcs operation: %s', action)
297 297 # check IP
298 298 inherit = user.inherit_default_permissions
299 299 ip_allowed = AuthUser.check_ip_allowed(
@@ -43,6 +43,7 b' from webhelpers2.text import collapse, s'
43 43 from mako import exceptions
44 44
45 45 from rhodecode import ConfigGet
46 from rhodecode.lib.exceptions import HTTPBranchProtected, HTTPLockedRC
46 47 from rhodecode.lib.hash_utils import sha256_safe, md5, sha1
47 48 from rhodecode.lib.type_utils import AttributeDict
48 49 from rhodecode.lib.str_utils import safe_bytes, safe_str
@@ -88,8 +89,36 b' def adopt_for_celery(func):'
88 89 try:
89 90 # HooksResponse implements to_json method which must be used there.
90 91 return func(extras).to_json()
92 except HTTPBranchProtected as error:
93 # Those special cases don't need error reporting. It's a case of
94 # locked repo or protected branch
95 error_args = error.args
96 return {
97 'status': error.code,
98 'output': error.explanation,
99 'exception': type(error).__name__,
100 'exception_args': error_args,
101 'exception_traceback': '',
102 }
103 except HTTPLockedRC as error:
104 # Those special cases don't need error reporting. It's a case of
105 # locked repo or protected branch
106 error_args = error.args
107 return {
108 'status': error.code,
109 'output': error.explanation,
110 'exception': type(error).__name__,
111 'exception_args': error_args,
112 'exception_traceback': '',
113 }
91 114 except Exception as e:
92 return {'status': 128, 'exception': type(e).__name__, 'exception_args': e.args}
115 return {
116 'status': 128,
117 'output': '',
118 'exception': type(e).__name__,
119 'exception_args': e.args,
120 'exception_traceback': '',
121 }
93 122 return wrapper
94 123
95 124
General Comments 0
You need to be logged in to leave comments. Login now