2018-10-08 10:50:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-25 10:16:25 -04:00
|
|
|
module SystemCheck
|
|
|
|
module App
|
|
|
|
class GitConfigCheck < SystemCheck::BaseCheck
|
|
|
|
OPTIONS = {
|
|
|
|
'core.autocrlf' => 'input'
|
|
|
|
}.freeze
|
|
|
|
|
2017-05-30 13:06:58 -04:00
|
|
|
set_name 'Git configured correctly?'
|
2017-05-25 10:16:25 -04:00
|
|
|
|
|
|
|
def check?
|
|
|
|
correct_options = OPTIONS.map do |name, value|
|
|
|
|
run_command(%W(#{Gitlab.config.git.bin_path} config --global --get #{name})).try(:squish) == value
|
|
|
|
end
|
|
|
|
|
|
|
|
correct_options.all?
|
|
|
|
end
|
|
|
|
|
2017-05-30 13:06:58 -04:00
|
|
|
# Tries to configure git itself
|
|
|
|
#
|
|
|
|
# Returns true if all subcommands were successful (according to their exit code)
|
|
|
|
# Returns false if any or all subcommands failed.
|
2017-05-25 10:16:25 -04:00
|
|
|
def repair!
|
2017-08-24 12:58:09 -04:00
|
|
|
return false unless gitlab_user?
|
2017-05-30 13:06:58 -04:00
|
|
|
|
|
|
|
command_success = OPTIONS.map do |name, value|
|
|
|
|
system(*%W(#{Gitlab.config.git.bin_path} config --global #{name} #{value}))
|
|
|
|
end
|
|
|
|
|
|
|
|
command_success.all?
|
2017-05-25 10:16:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def show_error
|
|
|
|
try_fixing_it(
|
|
|
|
sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS['core.autocrlf']}\"")
|
|
|
|
)
|
|
|
|
for_more_information(
|
|
|
|
see_installation_guide_section 'GitLab'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|