summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/create-hooks12
-rwxr-xr-xsupport/rewrite-hooks.sh29
2 files changed, 15 insertions, 26 deletions
diff --git a/bin/create-hooks b/bin/create-hooks
new file mode 100755
index 0000000..d6f07c7
--- /dev/null
+++ b/bin/create-hooks
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+# Recreate GitLab hooks in the Git repositories managed by GitLab.
+#
+# This script is used when restoring a GitLab backup.
+
+require_relative '../lib/gitlab_init'
+require File.join(ROOT_PATH, 'lib', 'gitlab_projects')
+
+Dir["#{GitlabConfig.new.repos_path}/*/*.git"].each do |repo|
+ GitlabProjects.create_hooks(repo)
+end
diff --git a/support/rewrite-hooks.sh b/support/rewrite-hooks.sh
index 3c96b6f..585eaeb 100755
--- a/support/rewrite-hooks.sh
+++ b/support/rewrite-hooks.sh
@@ -1,28 +1,5 @@
#!/bin/bash
+# This script is deprecated. Use bin/create-hooks instead.
-# $1 is an optional argument specifying the location of the repositories directory.
-# Defaults to /home/git/repositories if not provided
-
-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"
-}
-
-for dir in `ls "$src/"`
-do
- if [ -d "$src/$dir" ]; then
- if [[ "$dir" =~ ^.*\.git$ ]]
- then
- create_link_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"
- fi
- done
- fi
- fi
-done
+gitlab_shell_dir="$(cd $(dirname $0) && pwd)/.."
+exec ${gitlab_shell_dir}/bin/create-hooks