Commit f6415193 authored by Patrick Steinhardt's avatar Patrick Steinhardt

Do not assert creation of hook directories

The repository importer asserts that newly created repositories have a
"hooks" directory created. Historically, this fact was quite important
given that this was indeed a symlink to a directory containing Gitaly's
hook scripts. Nowadays though this is not required anymore given that
Gitaly locates hooks via the "core.hooksPath" config entry. As such, the
"hooks" directory will not contain anything specific but only the set of
default hook templates copied over by Git from the template directory.
These templates do not serve any purpose at all, except that they may
help authors of new hook scripts to discover which hooks exist and which
inputs they may get.

It is quite unlikely that an admin will develop hook scripts on a
production server by using the templates installed by Git, and in fact
the normal "hooks" directory isn't even used anymore given that we
override it in Gitaly. If an admin wants to install server-side hooks,
then those must be installed into a Gitaly-specific "custom_hooks"
directory anyway. So at best the initialized "hooks" directory does
nothing, at worst it is actively confusing to admins wanting to install
their own set of hooks.

In Gitaly, we have thus decided to get rid of the default templates
installed by git-init(1) and git-clone(1) completely. As a result, there
won't be a sample set of hooks, but there also won't be the template for
excludes in "info/excludes" or the default description in "description".
This not only fixes the confusion, but also saves a bit of disk space
and will help us at a later point to be able to bundle Git as a set of
binaries instead of requiring a full Git installation.

Long story short: to the best of my knowledge, Rails doesn't rely on
these files to exist, and they don't do anything anyway. There is one
test though which verifies that the hooks directory exists after having
created the repo, which will break when we stop installing templates. So
let's fix this test to not require presence of this directory anymore.
parent ea7a8d7b
......@@ -89,10 +89,8 @@ RSpec.describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
project = Project.find_by_full_path(project_path)
repo_path = "#{project.disk_path}.git"
hook_path = File.join(repo_path, 'hooks')
expect(gitlab_shell.repository_exists?(project.repository_storage, repo_path)).to be(true)
expect(TestEnv.storage_dir_exists?(project.repository_storage, hook_path)).to be(true)
end
context 'hashed storage enabled' 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