Commit 3ab33fcfca85e65931844124bda83148b6e27f69

Authored by Dmitriy Zaporozhets
1 parent b39002ce

Add post-receive file content validation

Showing 1 changed file with 12 additions and 5 deletions   Show diff stats
lib/tasks/gitlab/status.rake
... ... @@ -2,7 +2,7 @@ namespace :gitlab do
2 2 namespace :app do
3 3 desc "GITLAB | Check GitLab installation status"
4 4 task :status => :environment do
5   - puts "Starting diagnostics".yellow
  5 + puts "\nStarting diagnostics".yellow
6 6 git_base_path = Gitlab.config.git_base_path
7 7  
8 8 print "config/database.yml............"
... ... @@ -86,17 +86,24 @@ namespace :gitlab do
86 86 end
87 87  
88 88 if Project.count > 0
89   - puts "Validating projects repositories:".yellow
  89 + puts "\nValidating projects repositories:".yellow
90 90 Project.find_each(:batch_size => 100) do |project|
91   - print "#{project.name}....."
  91 + print "* #{project.name}....."
92 92 hook_file = File.join(project.path_to_repo, 'hooks', 'post-receive')
93 93  
94 94 unless File.exists?(hook_file)
95 95 puts "post-receive file missing".red
96   - return
  96 + next
97 97 end
98 98  
99   - puts "post-receive file ok".green
  99 + original_content = File.read(Rails.root.join('lib', 'hooks', 'post-receive'))
  100 + new_content = File.read(hook_file)
  101 +
  102 + if original_content == new_content
  103 + puts "post-receive file ok".green
  104 + else
  105 + puts "post-receive file content does not match".red
  106 + end
100 107 end
101 108 end
102 109  
... ...