Commit fac503877dbd3541009a30c8b9353d6eef85b059
1 parent
42dd006d
Exists in
master
and in
4 other branches
Port changes from #2803
Showing
1 changed file
with
47 additions
and
38 deletions
Show diff stats
lib/tasks/gitlab/check.rake
@@ -782,21 +782,25 @@ namespace :gitlab do | @@ -782,21 +782,25 @@ namespace :gitlab do | ||
782 | Project.find_each(batch_size: 100) do |project| | 782 | Project.find_each(batch_size: 100) do |project| |
783 | print "#{project.name_with_namespace.yellow} ... " | 783 | print "#{project.name_with_namespace.yellow} ... " |
784 | 784 | ||
785 | - correct_options = options.map do |name, value| | ||
786 | - run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value | ||
787 | - end | ||
788 | - | ||
789 | - if correct_options.all? | ||
790 | - puts "ok".green | 785 | + if project.empty_repo? |
786 | + puts "repository is empty".magenta | ||
791 | else | 787 | else |
792 | - puts "wrong or missing".red | ||
793 | - try_fixing_it( | ||
794 | - sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production") | ||
795 | - ) | ||
796 | - for_more_information( | ||
797 | - "doc/raketasks/maintenance.md" | ||
798 | - ) | ||
799 | - fix_and_rerun | 788 | + correct_options = options.map do |name, value| |
789 | + run("git --git-dir=\"#{project.repository.path_to_repo}\" config --get #{name}").try(:chomp) == value | ||
790 | + end | ||
791 | + | ||
792 | + if correct_options.all? | ||
793 | + puts "ok".green | ||
794 | + else | ||
795 | + puts "wrong or missing".red | ||
796 | + try_fixing_it( | ||
797 | + sudo_gitlab("bundle exec rake gitlab:gitolite:update_repos RAILS_ENV=production") | ||
798 | + ) | ||
799 | + for_more_information( | ||
800 | + "doc/raketasks/maintenance.md" | ||
801 | + ) | ||
802 | + fix_and_rerun | ||
803 | + end | ||
800 | end | 804 | end |
801 | end | 805 | end |
802 | end | 806 | end |
@@ -822,32 +826,37 @@ namespace :gitlab do | @@ -822,32 +826,37 @@ namespace :gitlab do | ||
822 | 826 | ||
823 | Project.find_each(batch_size: 100) do |project| | 827 | Project.find_each(batch_size: 100) do |project| |
824 | print "#{project.name_with_namespace.yellow} ... " | 828 | print "#{project.name_with_namespace.yellow} ... " |
825 | - project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file) | ||
826 | 829 | ||
827 | - unless File.exists?(project_hook_file) | ||
828 | - puts "missing".red | ||
829 | - try_fixing_it( | ||
830 | - "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" | ||
831 | - ) | ||
832 | - for_more_information( | ||
833 | - "lib/support/rewrite-hooks.sh" | ||
834 | - ) | ||
835 | - fix_and_rerun | ||
836 | - next | ||
837 | - end | ||
838 | - | ||
839 | - if File.lstat(project_hook_file).symlink? && | ||
840 | - File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) | ||
841 | - puts "ok".green | 830 | + if project.empty_repo? |
831 | + puts "repository is empty".magenta | ||
842 | else | 832 | else |
843 | - puts "not a link to Gitolite's hook".red | ||
844 | - try_fixing_it( | ||
845 | - "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" | ||
846 | - ) | ||
847 | - for_more_information( | ||
848 | - "lib/support/rewrite-hooks.sh" | ||
849 | - ) | ||
850 | - fix_and_rerun | 833 | + project_hook_file = File.join(project.repository.path_to_repo, "hooks", hook_file) |
834 | + | ||
835 | + unless File.exists?(project_hook_file) | ||
836 | + puts "missing".red | ||
837 | + try_fixing_it( | ||
838 | + "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" | ||
839 | + ) | ||
840 | + for_more_information( | ||
841 | + "lib/support/rewrite-hooks.sh" | ||
842 | + ) | ||
843 | + fix_and_rerun | ||
844 | + next | ||
845 | + end | ||
846 | + | ||
847 | + if File.lstat(project_hook_file).symlink? && | ||
848 | + File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) | ||
849 | + puts "ok".green | ||
850 | + else | ||
851 | + puts "not a link to Gitolite's hook".red | ||
852 | + try_fixing_it( | ||
853 | + "sudo -u #{gitolite_ssh_user} ln -sf #{gitolite_hook_file} #{project_hook_file}" | ||
854 | + ) | ||
855 | + for_more_information( | ||
856 | + "lib/support/rewrite-hooks.sh" | ||
857 | + ) | ||
858 | + fix_and_rerun | ||
859 | + end | ||
851 | end | 860 | end |
852 | end | 861 | end |
853 | end | 862 | end |