Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-09-18 16:18:36 +0400
committerMarin Jankovski <marin@gitlab.com>2014-09-18 16:18:36 +0400
commitd1be585ab541f15134823a0613b59265de9d4551 (patch)
treea58daf0e31e023ed05f805934797e1b7cbe51cf8
parent3fc5795bfbbb92c5fb03e34326d3d1f9edd94fe7 (diff)
parenta497e89fb97275d8c8f7db3ad6e9d9071a7ce046 (diff)
Merge branch 'fix_rake_gitlab_check' into '7-2-stable'
Check for hooks directory symlink in gitlab:check See merge request !1098
-rw-r--r--lib/tasks/gitlab/check.rake79
1 files changed, 17 insertions, 62 deletions
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 032ed5ee370..1972eda35bb 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -356,8 +356,7 @@ namespace :gitlab do
check_repo_base_user_and_group
check_repo_base_permissions
check_satellites_permissions
- check_update_hook_is_up_to_date
- check_repos_update_hooks_is_link
+ check_repos_hooks_directory_is_link
check_gitlab_shell_self_test
finished_checking "GitLab Shell"
@@ -367,29 +366,6 @@ namespace :gitlab do
# Checks
########################
-
- def check_update_hook_is_up_to_date
- print "update hook up-to-date? ... "
-
- hook_file = "update"
- gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path
- gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
-
- if File.exists?(gitlab_shell_hook_file)
- puts "yes".green
- else
- puts "no".red
- puts "Could not find #{gitlab_shell_hook_file}"
- try_fixing_it(
- 'Check the hooks_path in config/gitlab.yml',
- 'Check your gitlab-shell installation'
- )
- for_more_information(
- see_installation_guide_section "GitLab Shell"
- )
- end
- end
-
def check_repo_base_exists
print "Repo base directory exists? ... "
@@ -508,18 +484,10 @@ namespace :gitlab do
end
end
- def check_repos_update_hooks_is_link
- print "update hooks in repos are links: ... "
+ def check_repos_hooks_directory_is_link
+ print "hooks directories in repos are links: ... "
- hook_file = "update"
gitlab_shell_hooks_path = Gitlab.config.gitlab_shell.hooks_path
- gitlab_shell_hook_file = File.join(gitlab_shell_hooks_path, hook_file)
- gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user
-
- unless File.exists?(gitlab_shell_hook_file)
- puts "can't check because of previous errors".magenta
- return
- end
unless Project.count > 0
puts "can't check, you have no projects".magenta
@@ -529,38 +497,25 @@ namespace :gitlab do
Project.find_each(batch_size: 100) do |project|
print sanitized_message(project)
+ project_hook_directory = File.join(project.repository.path_to_repo, "hooks")
if project.empty_repo?
puts "repository is empty".magenta
+ elsif File.realpath(project_hook_directory) == File.realpath(gitlab_shell_hooks_path)
+ puts 'ok'.green
else
- project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file)
-
- unless File.exists?(project_hook_file)
- puts "missing".red
- try_fixing_it(
- "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
- )
- for_more_information(
- "#{gitlab_shell_path}/support/rewrite-hooks.sh"
- )
- fix_and_rerun
- next
- end
-
- if File.lstat(project_hook_file).symlink? &&
- File.realpath(project_hook_file) == File.realpath(gitlab_shell_hook_file)
- puts "ok".green
- else
- puts "not a link to GitLab Shell's hook".red
- try_fixing_it(
- "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
- )
- for_more_information(
- "lib/support/rewrite-hooks.sh"
- )
- fix_and_rerun
- end
+ puts "wrong or missing hooks".red
+ try_fixing_it(
+ sudo_gitlab("#{gitlab_shell_path}/bin/create-hooks"),
+ 'Check the hooks_path in config/gitlab.yml',
+ 'Check your gitlab-shell installation'
+ )
+ for_more_information(
+ see_installation_guide_section "GitLab Shell"
+ )
+ fix_and_rerun
end
+
end
end