Commit cb8f331c authored by Kirill Smelkov's avatar Kirill Smelkov

There is no need to keep old hooks around - remove them

gitlab-shell uses completely own whole set of git hooks and just
symlinks repo.git/hooks to path/to/gitlab-shell/hooks/.

Original hooks that git added there - when initializing repository -
from its template, and which are by default deactivated, are currently
moved to repos.git/hooks.old.<timestamp>, e.g.

$ ls -F nexedi/helloweb.git/
    config
    description
    HEAD
    hooks@                  -->  ...path/to/gitlab-shell/hooks/
    hooks.old.1446564288/
    info/
    packed-refs
    refs/

$ ls -F nexedi/helloweb.git/hooks.old.1446564288/
    applypatch-msg.sample*
    post-update.sample*
    pre-commit.sample*
    pre-push.sample*
    update.sample*
    commit-msg.sample*
    pre-applypatch.sample*
    prepare-commit-msg.sample*
    pre-rebase.sample*

On the other hand, hooks.old.<timestamp> are not used anywhere and are
left there "just in case". But what is the point to keep those pristine
samples git creates by default? And we are sure those files are always
results of gitlab-shell initializing a repository, as it is
gitlab-shell's job to create/remove/update/etc repositories.

So do not keep old hooks, remove them.

P.S. The patch that introduced whole-hooks-dir-symlinking is
    db81327b (Symlink the whole hooks directory).

/cc @dzaporozhets, @jacobvosmaer
parent ff31080b
Pipeline #509 failed with stage
...@@ -30,8 +30,8 @@ class GitlabProjects ...@@ -30,8 +30,8 @@ class GitlabProjects
if real_local_hooks_directory != File.realpath(GLOBAL_HOOKS_DIRECTORY) if real_local_hooks_directory != File.realpath(GLOBAL_HOOKS_DIRECTORY)
if File.exist?(local_hooks_directory) if File.exist?(local_hooks_directory)
$logger.info "Moving existing hooks directory and symlinking global hooks directory for #{path}." $logger.info "Removing existing hooks directory and symlinking global hooks directory for #{path}."
FileUtils.mv(local_hooks_directory, "#{local_hooks_directory}.old.#{Time.now.to_i}") FileUtils.remove_dir(local_hooks_directory)
end end
FileUtils.ln_sf(GLOBAL_HOOKS_DIRECTORY, local_hooks_directory) FileUtils.ln_sf(GLOBAL_HOOKS_DIRECTORY, local_hooks_directory)
else else
......
...@@ -33,7 +33,7 @@ describe GitlabProjects do ...@@ -33,7 +33,7 @@ describe GitlabProjects do
end end
it { File.readlink(hooks_dir).should == target_hooks_dir } it { File.readlink(hooks_dir).should == target_hooks_dir }
it { Dir[File.join(repo_path, "hooks.old.*/my-file")].count.should == 1 } it { Dir[File.join(repo_path, "hooks.old.*/my-file")].count.should == 0 }
end end
context 'hooks is a valid symlink' do context 'hooks is a valid symlink' do
......
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