##// END OF EJS Templates
vcs: Do not trigger external hook in case of actions on shadow respositories.
Martin Bornhold -
r900:3895c836 default
parent child Browse files
Show More
@@ -38,6 +38,13 b' from rhodecode.model.db import Repositor'
38 38 HookResponse = collections.namedtuple('HookResponse', ('status', 'output'))
39 39
40 40
41 def is_shadow_repo(extras):
42 """
43 Returns ``True`` if this is an action executed against a shadow repository.
44 """
45 return extras['is_shadow_repo']
46
47
41 48 def _get_scm_size(alias, root_path):
42 49
43 50 if not alias.startswith('.'):
@@ -85,7 +92,6 b' def pre_push(extras):'
85 92 """
86 93 usr = User.get_by_username(extras.username)
87 94
88
89 95 output = ''
90 96 if extras.locked_by[0] and usr.user_id != int(extras.locked_by[0]):
91 97 locked_by = User.get(extras.locked_by[0]).username
@@ -100,11 +106,12 b' def pre_push(extras):'
100 106 else:
101 107 raise _http_ret
102 108
103 # Calling hooks after checking the lock, for consistent behavior
104 pre_push_extension(repo_store_path=Repository.base_path(), **extras)
105
106 events.trigger(events.RepoPrePushEvent(repo_name=extras.repository,
107 extras=extras))
109 # Propagate to external components. This is done after checking the
110 # lock, for consistent behavior.
111 if not is_shadow_repo(extras):
112 pre_push_extension(repo_store_path=Repository.base_path(), **extras)
113 events.trigger(events.RepoPrePushEvent(
114 repo_name=extras.repository, extras=extras))
108 115
109 116 return HookResponse(0, output)
110 117
@@ -130,10 +137,12 b' def pre_pull(extras):'
130 137 else:
131 138 raise _http_ret
132 139
133 # Calling hooks after checking the lock, for consistent behavior
134 pre_pull_extension(**extras)
135 events.trigger(events.RepoPrePullEvent(repo_name=extras.repository,
136 extras=extras))
140 # Propagate to external components. This is done after checking the
141 # lock, for consistent behavior.
142 if not is_shadow_repo(extras):
143 pre_pull_extension(**extras)
144 events.trigger(events.RepoPrePullEvent(
145 repo_name=extras.repository, extras=extras))
137 146
138 147 return HookResponse(0, output)
139 148
@@ -144,14 +153,15 b' def post_pull(extras):'
144 153 action = 'pull'
145 154 action_logger(user, action, extras.repository, extras.ip, commit=True)
146 155
147 events.trigger(events.RepoPullEvent(repo_name=extras.repository,
148 extras=extras))
149 # extension hook call
150 post_pull_extension(**extras)
156 # Propagate to external components.
157 if not is_shadow_repo(extras):
158 post_pull_extension(**extras)
159 events.trigger(events.RepoPullEvent(
160 repo_name=extras.repository, extras=extras))
151 161
152 162 output = ''
153 163 # make lock is a tri state False, True, None. We only make lock on True
154 if extras.make_lock is True:
164 if extras.make_lock is True and not is_shadow_repo(extras):
155 165 Repository.lock(Repository.get_by_repo_name(extras.repository),
156 166 user.user_id,
157 167 lock_reason=Repository.LOCK_PULL)
@@ -179,19 +189,20 b' def post_push(extras):'
179 189 action_logger(
180 190 extras.username, action, extras.repository, extras.ip, commit=True)
181 191
182 events.trigger(events.RepoPushEvent(repo_name=extras.repository,
183 pushed_commit_ids=commit_ids,
184 extras=extras))
185
186 # extension hook call
187 post_push_extension(
188 repo_store_path=Repository.base_path(),
189 pushed_revs=commit_ids,
190 **extras)
192 # Propagate to external components.
193 if not is_shadow_repo(extras):
194 post_push_extension(
195 repo_store_path=Repository.base_path(),
196 pushed_revs=commit_ids,
197 **extras)
198 events.trigger(events.RepoPushEvent(
199 repo_name=extras.repository,
200 pushed_commit_ids=commit_ids,
201 extras=extras))
191 202
192 203 output = ''
193 204 # make lock is a tri state False, True, None. We only release lock on False
194 if extras.make_lock is False:
205 if extras.make_lock is False and not is_shadow_repo(extras):
195 206 Repository.unlock(Repository.get_by_repo_name(extras.repository))
196 207 msg = 'Released lock on repo `%s`\n' % extras.repository
197 208 output += msg
General Comments 0
You need to be logged in to leave comments. Login now