Commit 4d1b2b88 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Symlink the whole hooks directory

Conflicts:
	CHANGELOG
	lib/gitlab_projects.rb
parent 33c2bca5
v1.9.8 v1.9.8
- Ignore missing repositories in create-hooks - Ignore missing repositories in create-hooks
- Symlink the whole hooks directory
v1.9.7 v1.9.7
- Increased test coverage - Increased test coverage
......
...@@ -5,6 +5,8 @@ require_relative 'gitlab_config' ...@@ -5,6 +5,8 @@ require_relative 'gitlab_config'
require_relative 'gitlab_logger' require_relative 'gitlab_logger'
class GitlabProjects class GitlabProjects
GLOBAL_HOOKS_DIRECTORY = File.join(ROOT_PATH, 'hooks')
# Project name is a directory name for repository with .git at the end # 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 # It may be namespaced or not. Like repo.git or gitlab/repo.git
attr_reader :project_name attr_reader :project_name
...@@ -18,9 +20,11 @@ class GitlabProjects ...@@ -18,9 +20,11 @@ class GitlabProjects
attr_reader :full_path attr_reader :full_path
def self.create_hooks(path) def self.create_hooks(path)
hook = File.join(path, 'hooks', 'update') local_hooks_directory = File.join(path, 'hooks')
File.delete(hook) if File.exists?(hook) unless File.realpath(local_hooks_directory) == File.realpath(GLOBAL_HOOKS_DIRECTORY)
File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), hook) FileUtils.mv(local_hooks_directory, "#{local_hooks_directory}.#{Time.now.to_i}")
FileUtils.ln_s(GLOBAL_HOOKS_DIRECTORY, local_hooks_directory)
end
end end
def initialize def initialize
......
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