summaryrefslogtreecommitdiff
path: root/lib/gitlab_projects.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2014-09-16 15:05:03 +0200
committerJacob Vosmaer <contact@jacobvosmaer.nl>2014-09-16 15:05:03 +0200
commitdb81327b909e2674312e53c97c742c35f432c5bd (patch)
treea370682cf3154c7538892c0067f861d910ad0e22 /lib/gitlab_projects.rb
parent27fe2ea53530709b9d51915d9cd95912c9be0a06 (diff)
downloadgitlab-shell-db81327b909e2674312e53c97c742c35f432c5bd.tar.gz
Symlink the whole hooks directory
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r--lib/gitlab_projects.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index d6922c6..a216d8b 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -5,6 +5,8 @@ require_relative 'gitlab_config'
require_relative 'gitlab_logger'
class GitlabProjects
+ GLOBAL_HOOKS_DIRECTORY = File.join(ROOT_PATH, 'hooks')
+
# Project name is a directory name for repository with .git at the end
# It may be namespaced or not. Like repo.git or gitlab/repo.git
attr_reader :project_name
@@ -18,10 +20,10 @@ class GitlabProjects
attr_reader :full_path
def self.create_hooks(path)
- %w(pre-receive post-receive).each do |hook_name|
- hook = File.join(path, 'hooks', hook_name)
- File.delete(hook) if File.exists?(hook)
- File.symlink(File.join(ROOT_PATH, 'hooks', hook_name), hook)
+ local_hooks_directory = File.join(path, 'hooks')
+ unless File.realpath(local_hooks_directory) == File.realpath(GLOBAL_HOOKS_DIRECTORY)
+ FileUtils.mv(local_hooks_directory, "#{local_hooks_directory}.#{Time.now.to_i}")
+ FileUtils.ln_s(GLOBAL_HOOKS_DIRECTORY, local_hooks_directory)
end
end