2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module SystemCheck
|
|
|
|
module App
|
|
|
|
class GitConfigCheck < SystemCheck::BaseCheck
|
|
|
|
OPTIONS = {
|
|
|
|
'core.autocrlf' => 'input'
|
|
|
|
}.freeze
|
|
|
|
|
|
|
|
set_name 'Git configured correctly?'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
def repair!
|
2018-03-17 18:26:18 +05:30
|
|
|
return false unless gitlab_user?
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
command_success = OPTIONS.map do |name, value|
|
|
|
|
system(*%W(#{Gitlab.config.git.bin_path} config --global #{name} #{value}))
|
|
|
|
end
|
|
|
|
|
|
|
|
command_success.all?
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_error
|
|
|
|
try_fixing_it(
|
|
|
|
sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS['core.autocrlf']}\"")
|
|
|
|
)
|
|
|
|
for_more_information(
|
2020-04-22 19:07:51 +05:30
|
|
|
see_installation_guide_section('GitLab')
|
2017-09-10 17:25:29 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|