Check if project.repository before check

Fix for #2776
This commit is contained in:
Donny Kurnia 2013-01-28 21:53:41 +07:00
parent d14069e333
commit 59d91729c8

View file

@ -778,23 +778,25 @@ namespace :gitlab do
} }
Project.find_each(batch_size: 100) do |project| Project.find_each(batch_size: 100) do |project|
print "#{project.name_with_namespace.yellow} ... " if project.repository
print "#{project.name_with_namespace.yellow} ... "
correct_options = options.map do |name, value| correct_options = options.map do |name, value|
run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value
end end
if correct_options.all? if correct_options.all?
puts "ok".green puts "ok".green
else else
puts "wrong or missing".red puts "wrong or missing".red
try_fixing_it( try_fixing_it(
sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos") sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos")
) )
for_more_information( for_more_information(
"doc/raketasks/maintenance.md" "doc/raketasks/maintenance.md"
) )
fix_and_rerun fix_and_rerun
end
end end
end end
end end
@ -819,33 +821,35 @@ namespace :gitlab do
puts "" puts ""
Project.find_each(batch_size: 100) do |project| Project.find_each(batch_size: 100) do |project|
print "#{project.name_with_namespace.yellow} ... " if project.repository
project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file) print "#{project.name_with_namespace.yellow} ... "
project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file)
unless File.exists?(project_hook_file) unless File.exists?(project_hook_file)
puts "missing".red puts "missing".red
try_fixing_it( try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
) )
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
) )
fix_and_rerun fix_and_rerun
next next
end end
if File.lstat(project_hook_file).symlink? && if File.lstat(project_hook_file).symlink? &&
File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) File.realpath(project_hook_file) == File.realpath(gitolite_hook_file)
puts "ok".green puts "ok".green
else else
puts "not a link to Gitolite's hook".red puts "not a link to Gitolite's hook".red
try_fixing_it( try_fixing_it(
"sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}"
) )
for_more_information( for_more_information(
"lib/support/rewrite-hooks.sh" "lib/support/rewrite-hooks.sh"
) )
fix_and_rerun fix_and_rerun
end
end end
end end
end end