summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-16 15:10:55 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-16 15:10:55 +0000
commit9ab685c80205167caf3f41bb65598c2e17fbea90 (patch)
treed214916db554b93bf6cf79a74c72fbe9ccf23777
parent33c2bca58cb38944779490a205275199dc4b063a (diff)
parentcc1bf32edeac5ab4326688f1b4c6154d5f058577 (diff)
downloadgitlab-shell-9ab685c80205167caf3f41bb65598c2e17fbea90.tar.gz
Merge branch '1.9.8-symlink-hooks-directory' into 'version-1-9'
1.9.8: symlink hooks directory See merge request !45
-rw-r--r--CHANGELOG1
-rw-r--r--lib/gitlab_projects.rb10
2 files changed, 8 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 12cb346..128df55 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,6 @@
v1.9.8
- Ignore missing repositories in create-hooks
+ - Symlink the whole hooks directory
v1.9.7
- Increased test coverage
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index a6fa1b5..587f029 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,9 +20,11 @@ class GitlabProjects
attr_reader :full_path
def self.create_hooks(path)
- hook = File.join(path, 'hooks', 'update')
- File.delete(hook) if File.exists?(hook)
- File.symlink(File.join(ROOT_PATH, 'hooks', 'update'), 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}.old.#{Time.now.to_i}")
+ FileUtils.ln_s(GLOBAL_HOOKS_DIRECTORY, local_hooks_directory)
+ end
end
def initialize