Commit 17691041 authored by Elan Ruusamäe's avatar Elan Ruusamäe Committed by Sean McGivern

move helpers to top

parent 91ba6396
...@@ -16,6 +16,35 @@ describe GitlabCustomHook do ...@@ -16,6 +16,35 @@ describe GitlabCustomHook do
let(:gitlab_custom_hook) { GitlabCustomHook.new(tmp_repo_path, 'key_1') } let(:gitlab_custom_hook) { GitlabCustomHook.new(tmp_repo_path, 'key_1') }
def hook_path(repo_path, path)
File.join(repo_path, path.split('/'))
end
def create_hook(repo_path, path, which)
FileUtils.ln_sf(which, hook_path(repo_path, path))
end
# global hooks multiplexed
def create_global_hooks_d(path, which)
create_hook(path, 'hooks/pre-receive.d/hook', which)
create_hook(path, 'hooks/update.d/hook', which)
create_hook(path, 'hooks/post-receive.d/hook', which)
end
# repo hooks
def create_repo_hooks(path, which)
create_hook(path, 'custom_hooks/pre-receive', which)
create_hook(path, 'custom_hooks/update', which)
create_hook(path, 'custom_hooks/post-receive', which)
end
# repo hooks multiplexed
def create_repo_hooks_d(path, which)
create_hook(path, 'custom_hooks/pre-receive.d/hook', which)
create_hook(path, 'custom_hooks/update.d/hook', which)
create_hook(path, 'custom_hooks/post-receive.d/hook', which)
end
# setup paths # setup paths
# <repository>.git/hooks/ - symlink to gitlab-shell/hooks global dir # <repository>.git/hooks/ - symlink to gitlab-shell/hooks global dir
# <repository>.git/hooks/<hook_name> - executed by git itself, this is gitlab-shell/hooks/<hook_name> # <repository>.git/hooks/<hook_name> - executed by git itself, this is gitlab-shell/hooks/<hook_name>
...@@ -173,33 +202,4 @@ describe GitlabCustomHook do ...@@ -173,33 +202,4 @@ describe GitlabCustomHook do
gitlab_custom_hook.post_receive(changes) gitlab_custom_hook.post_receive(changes)
end end
end end
def hook_path(repo_path, path)
File.join(repo_path, path.split('/'))
end
def create_hook(repo_path, path, which)
FileUtils.ln_sf(which, hook_path(repo_path, path))
end
# global hooks multiplexed
def create_global_hooks_d(path, which)
create_hook(path, 'hooks/pre-receive.d/hook', which)
create_hook(path, 'hooks/update.d/hook', which)
create_hook(path, 'hooks/post-receive.d/hook', which)
end
# repo hooks
def create_repo_hooks(path, which)
create_hook(path, 'custom_hooks/pre-receive', which)
create_hook(path, 'custom_hooks/update', which)
create_hook(path, 'custom_hooks/post-receive', which)
end
# repo hooks multiplexed
def create_repo_hooks_d(path, which)
create_hook(path, 'custom_hooks/pre-receive.d/hook', which)
create_hook(path, 'custom_hooks/update.d/hook', which)
create_hook(path, 'custom_hooks/post-receive.d/hook', which)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment