As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit db81327b authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

Symlink the whole hooks directory

parent 27fe2ea5
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,6 +3,7 @@ v2.0.0
- Replace raise with abort when checking path to prevent path exposure
- Handle invalid number of arguments on remote commands
- Replace update hook with pre-receive and post-receive hooks.
- Symlink the whole hooks directory
- Ignore missing repositories in create-hooks
- Connect to Redis via sockets by default
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment