Commit e73b68a7 authored by Semyon Pupkov's avatar Semyon Pupkov

Add git version to gitlab:env:info

https://gitlab.com/gitlab-org/gitlab-ce/issues/25376
parent 58758bd5
---
title: Add git version to gitlab:env:info
merge_request: 9128
author: Semyon Pupkov
...@@ -14,6 +14,8 @@ namespace :gitlab do ...@@ -14,6 +14,8 @@ namespace :gitlab do
rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s) rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s)
# check redis version # check redis version
redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a
# check Git version
git_version = run_and_match([Gitlab.config.git.bin_path, '--version'], /git version ([\d\.]+)/).to_a
puts "" puts ""
puts "System information".color(:yellow) puts "System information".color(:yellow)
...@@ -26,6 +28,7 @@ namespace :gitlab do ...@@ -26,6 +28,7 @@ namespace :gitlab do
puts "Bundler Version:#{bunder_version || "unknown".color(:red)}" puts "Bundler Version:#{bunder_version || "unknown".color(:red)}"
puts "Rake Version:\t#{rake_version || "unknown".color(:red)}" puts "Rake Version:\t#{rake_version || "unknown".color(:red)}"
puts "Redis Version:\t#{redis_version[1] || "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 "Sidekiq Version:#{Sidekiq::VERSION}"
# check database adapter # check database adapter
......
require 'rake_helper'
describe 'gitlab:env:info' 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