debian-mirror-gitlab/lib/gitlab/verify/rake_task.rb

56 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-23 12:14:25 +05:30
# frozen_string_literal: true
2018-03-27 19:54:05 +05:30
module Gitlab
module Verify
class RakeTask
def self.run!(verify_kls)
verifier = verify_kls.new(
batch_size: ENV.fetch('BATCH', 200).to_i,
start: ENV['ID_FROM'],
finish: ENV['ID_TO']
)
verbose = Gitlab::Utils.to_boolean(ENV['VERBOSE'])
new(verifier, verbose).run!
end
attr_reader :verifier, :output
def initialize(verifier, verbose)
@verifier = verifier
@verbose = verbose
end
def run!
say "Checking integrity of #{verifier.name}"
verifier.run_batches { |*args| run_batch(*args) }
say 'Done!'
end
def verbose?
!!@verbose
end
private
def say(text)
puts(text) # rubocop:disable Rails/Output
end
def run_batch(range, failures)
status_color = failures.empty? ? :green : :red
say "- #{range}: Failures: #{failures.count}".color(status_color)
return unless verbose?
failures.each do |object, error|
2018-11-08 19:23:39 +05:30
say " - #{verifier.describe(object)}: #{error}".color(:red)
2018-03-27 19:54:05 +05:30
end
end
end
end
end