summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-12-14 11:49:35 +0100
committerJames Lopez <james@jameslopez.es>2018-01-04 11:22:43 +0100
commit260935868acfb7c0cb720088d4f8c4c1c1088ddb (patch)
treec36ca5bef8cb9dd079705e59856ad11f29fbf109
parentac409fb44402622dfd6abb076f7a85df4b27d39d (diff)
downloadgitlab-ce-260935868acfb7c0cb720088d4f8c4c1c1088ddb.tar.gz
add new git fsck rake task and spec
-rw-r--r--lib/tasks/gitlab/git.rake10
-rw-r--r--spec/tasks/gitlab/git_rake_spec.rb27
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/git.rake b/lib/tasks/gitlab/git.rake
index cf82134d97e..f3ffff43726 100644
--- a/lib/tasks/gitlab/git.rake
+++ b/lib/tasks/gitlab/git.rake
@@ -30,6 +30,16 @@ namespace :gitlab do
end
end
+ desc 'GitLab | Git | Check all repos integrity'
+ task fsck: :environment do
+ failures = perform_git_cmd(%W(#{Gitlab.config.git.bin_path} fsck --name-objects --no-progress), "Checking integrity")
+ if failures.empty?
+ puts "Done".color(:green)
+ else
+ output_failures(failures)
+ end
+ end
+
def perform_git_cmd(cmd, message)
puts "Starting #{message} on all repositories"
diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb
new file mode 100644
index 00000000000..63a7f7efe73
--- /dev/null
+++ b/spec/tasks/gitlab/git_rake_spec.rb
@@ -0,0 +1,27 @@
+require 'rake_helper'
+
+describe 'gitlab:git rake tasks' do
+ before do
+ Rake.application.rake_require 'tasks/gitlab/git'
+
+ stub_warn_user_is_not_gitlab
+
+ FileUtils.mkdir(Settings.absolute('tmp/tests/default_storage'))
+ end
+
+ after do
+ FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage'))
+ end
+
+ describe 'fsck' do
+ let(:storages) do
+ { 'default' => { 'path' => Settings.absolute('tmp/tests/default_storage') } }
+ end
+
+ it 'outputs the right git command' do
+ expect(Kernel).to receive(:system).with('').and_return(true)
+
+ run_rake_task('gitlab:git:fsck')
+ end
+ end
+end