Skip to content

Commit ddc5b77

Browse files
Added a warning if you're using an old version of git.
1 parent 1455f9a commit ddc5b77

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/git.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
require 'git/stashes'
2727
require 'git/stash'
2828

29+
minimum_version = [1, 6, 0, 0]
30+
current_version = Git::Lib.new(nil, nil).command_version
31+
if current_version[0] < minimum_version[0] ||
32+
current_version[1] < minimum_version[1] ||
33+
current_version[2] < minimum_version[2] ||
34+
current_version[3] < minimum_version[3]
35+
$stderr.puts "The git gem requires git #{minimum_version.join('.')} or later, but only found #{current_version.join('.')}. You should probably upgrad.e"
36+
end
2937

3038
# Git/Ruby Library
3139
#

lib/git/lib.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,14 @@ def archive(sha, file = nil, opts = {})
643643
command('archive', arr_opts, true, (opts[:add_gzip] ? '| gzip' : '') + " > #{escape file}")
644644
return file
645645
end
646-
646+
647+
# returns the current version of git, as an Array of Fixnums.
648+
def command_version
649+
output = command('version', [], false)
650+
version = output[/(\d+)\.(\d+)\.(\d+)\.(\d+)/]
651+
version.split('.').collect {|i| i.to_i}
652+
end
653+
647654
private
648655

649656
def command_lines(cmd, opts = [], chdir = true, redirect = '')

0 commit comments

Comments
 (0)