# HG changeset patch # User Marcin Kuzminski # Date 2019-09-22 16:03:25 # Node ID baf64debbd080e9e878bf1ee0bfba06d742ad0dc # Parent 0cdda75fdb2094de1e7537221b07ade10ee354db hooks: added shadow repo dedicated dummy hook. It now should do nothing, since we don't want hooks execution on shadow repositories. diff --git a/vcsserver/hooks.py b/vcsserver/hooks.py --- a/vcsserver/hooks.py +++ b/vcsserver/hooks.py @@ -81,6 +81,12 @@ class HooksDummyClient(object): return getattr(hooks, hook_name)(extras) +class HooksShadowRepoClient(object): + + def __call__(self, hook_name, extras): + return {'output': '', 'status': 0} + + class RemoteMessageWriter(object): """Writer base class.""" def write(self, message): @@ -141,9 +147,12 @@ def _handle_exception(result): def _get_hooks_client(extras): - if 'hooks_uri' in extras: - protocol = extras.get('hooks_protocol') + hooks_uri = extras.get('hooks_uri') + is_shadow_repo = extras.get('is_shadow_repo') + if hooks_uri: return HooksHttpClient(extras['hooks_uri']) + elif is_shadow_repo: + return HooksShadowRepoClient() else: return HooksDummyClient(extras['hooks_module'])