diff options
author | Wouter D'Haeseleer <wouter.dhaeseleer@vasco.com> | 2013-07-15 13:01:09 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2013-08-26 10:16:24 +0200 |
commit | 4fc02372fe62f4f1b4c6618707de56c11ecc8451 (patch) | |
tree | 33c66ab040555a8aaa013c15eede9aed3c4d2585 | |
parent | fbaf8d8c12dcb9d820d250b9f9589318dbc36616 (diff) | |
download | gitlab-shell-4fc02372fe62f4f1b4c6618707de56c11ecc8451.tar.gz |
Just symlink all hooks found in the gitlab-shell project
Make it possible to place whatever hooks you want inside the hook
folder of the gitlab-shell and they will be symlinked as well. The
symlinks are created when:
* running the support/rewrite-hooks.sh
* Creating a new repo in gitlab
So basically it makes the hooks folder a skeleton for all other projects
-rw-r--r-- | lib/gitlab_projects.rb | 5 | ||||
-rw-r--r-- | spec/gitlab_projects_spec.rb | 2 | ||||
-rwxr-xr-x | support/rewrite-hooks.sh | 10 |
3 files changed, 11 insertions, 6 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index bea5686..0628335 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -182,6 +182,9 @@ class GitlabProjects private def create_hooks_to(dest_path) - "ln -s #{File.join(ROOT_PATH, 'hooks', 'update')} #{dest_path}/hooks/update" + symlink_cmds = Dir[File.join(ROOT_PATH, 'hooks', '*')].sort.map do |hook| + "ln -s #{hook} #{dest_path}/hooks/" + end + symlink_cmds.join(' && ') end end diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index 6ff72ec..2b36b34 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -101,7 +101,7 @@ describe GitlabProjects do it "should receive valid cmd" do valid_cmd = "cd #{tmp_repo_path} && git init --bare" - valid_cmd << " && ln -s #{ROOT_PATH}/hooks/update #{tmp_repo_path}/hooks/update" + valid_cmd << " && ln -s #{ROOT_PATH}/hooks/update #{tmp_repo_path}/hooks/" gl_projects.should_receive(:system).with(valid_cmd) gl_projects.exec end diff --git a/support/rewrite-hooks.sh b/support/rewrite-hooks.sh index 3c96b6f..0813b1c 100755 --- a/support/rewrite-hooks.sh +++ b/support/rewrite-hooks.sh @@ -6,8 +6,10 @@ home_dir="/home/git" src=${1:-"$home_dir/repositories"} -function create_link_in { - ln -s -f "$home_dir/gitlab-shell/hooks/update" "$1/hooks/update" +function create_links_in { + for gitlab_shell_hooks in ${home_dir}/gitlab-shell/hooks/* ; do + ln -s -f "$gitlab_shell_hooks" "$1/hooks/" + done } for dir in `ls "$src/"` @@ -15,12 +17,12 @@ do if [ -d "$src/$dir" ]; then if [[ "$dir" =~ ^.*\.git$ ]] then - create_link_in "$src/$dir" + create_links_in "$src/$dir" else for subdir in `ls "$src/$dir/"` do if [ -d "$src/$dir/$subdir" ] && [[ "$subdir" =~ ^.*\.git$ ]]; then - create_link_in "$src/$dir/$subdir" + create_links_in "$src/$dir/$subdir" fi done fi |