Commit a144c872 authored by Stan Hu's avatar Stan Hu

Merge branch 'pks-git-drop-legacy-functionality' into 'master'

Remove legacy restrictions on the Git installation

See merge request gitlab-org/gitlab!80048
parents 660000b6 7eb8487d
......@@ -560,10 +560,6 @@ sudo -u git -H cp config/puma.rb.example config/puma.rb
# cores you have available. You can get that number via the `nproc` command.
sudo -u git -H editor config/puma.rb
# Configure Git global settings for git user
# 'autocrlf' is needed for the web editor
sudo -u git -H git config --global core.autocrlf input
# Disable 'git gc --auto' because GitLab already runs 'git gc' when needed
sudo -u git -H git config --global gc.auto 0
......
......@@ -95,10 +95,6 @@ module Gitlab
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def git_bin_path
Gitlab.config.git.bin_path
end
def copy_files(source, destination)
# if we are copying files, create the destination folder
destination_folder = File.file?(source) ? File.dirname(destination) : destination
......
# frozen_string_literal: true
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!
return false unless gitlab_user?
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(
see_installation_guide_section('GitLab')
)
end
end
end
end
# frozen_string_literal: true
module SystemCheck
module App
class GitVersionCheck < SystemCheck::BaseCheck
set_name -> { "Git version >= #{self.required_version} ?" }
set_check_pass -> { "yes (#{self.current_version})" }
def self.required_version
@required_version ||= Gitlab::VersionInfo.parse('2.33.0')
end
def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W(#{Gitlab.config.git.bin_path} --version)))
end
def check?
self.class.current_version.valid? && self.class.required_version <= self.class.current_version
end
def show_error
$stdout.puts "Your git bin path is \"#{Gitlab.config.git.bin_path}\""
try_fixing_it(
"Update your git to a version >= #{self.class.required_version} from #{self.class.current_version}"
)
fix_and_rerun
end
end
end
end
......@@ -12,7 +12,6 @@ module SystemCheck
def self.checks
[
SystemCheck::App::GitConfigCheck,
SystemCheck::App::DatabaseConfigExistsCheck,
SystemCheck::App::MigrationsAreUpCheck,
SystemCheck::App::OrphanedGroupMembersCheck,
......@@ -28,7 +27,6 @@ module SystemCheck
SystemCheck::App::ProjectsHaveNamespaceCheck,
SystemCheck::App::RedisVersionCheck,
SystemCheck::App::RubyVersionCheck,
SystemCheck::App::GitVersionCheck,
SystemCheck::App::GitUserDefaultSSHConfigCheck,
SystemCheck::App::ActiveUsersCheck,
SystemCheck::App::AuthorizedKeysPermissionCheck,
......
......@@ -22,8 +22,6 @@ namespace :gitlab do
proxies = Gitlab::Proxy.detect_proxy.map {|k, v| "#{k}: #{v}"}.join("\n\t\t")
end
# check Git version
git_version = run_and_match([Gitlab.config.git.bin_path, '--version'], /git version ([\d\.]+)/).to_a
# check Go version
go_version = run_and_match(%w(go version), /go version (.+)/).to_a
......@@ -43,7 +41,6 @@ namespace :gitlab do
puts "Bundler Version:#{bunder_version || "unknown".color(:red)}"
puts "Rake Version:\t#{rake_version || "unknown".color(:red)}"
puts "Redis Version:\t#{redis_version[1] || "unknown".color(:red)}"
puts "Git Version:\t#{git_version[1] || "unknown".color(:red)}"
puts "Sidekiq Version:#{Sidekiq::VERSION}"
puts "Go Version:\t#{go_version[1] || "unknown".color(:red)}"
......@@ -95,7 +92,6 @@ namespace :gitlab do
end
end
puts "GitLab Shell path:\t\t#{Gitlab.config.gitlab_shell.path}"
puts "Git:\t\t#{Gitlab.config.git.bin_path}"
end
end
end
# frozen_string_literal: true
require 'rake_helper'
RSpec.describe 'gitlab:env:info', :silence_stdout do
before do
Rake.application.rake_require 'tasks/gitlab/info'
stub_warn_user_is_not_gitlab
allow(Gitlab::Popen).to receive(:popen)
end
describe 'git version' do
before do
allow(Gitlab::Popen).to receive(:popen).with([Gitlab.config.git.bin_path, '--version'])
.and_return(git_version)
end
context 'when git installed' do
let(:git_version) { 'git version 2.10.0' }
it 'prints git version' do
run_rake_task('gitlab:env:info')
expect($stdout.string).to match(/Git Version:(.*)2.10.0/)
end
end
context 'when git not installed' do
let(:git_version) { '' }
it 'prints unknown' do
run_rake_task('gitlab:env:info')
expect($stdout.string).to match(/Git Version:(.*)unknown/)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment