Browse files

Clone support for git < 1.6.5

  • Loading branch information...
1 parent a8703f5 commit e74fd7f198f111c021a62224f61746a6ed693105 Michal Bugno committed Dec 12, 2010
Showing with 21 additions and 1 deletion.
  1. +21 −1 extras/big_tuna/vcs/git.rb
View
22 extras/big_tuna/vcs/git.rb
@@ -13,6 +13,22 @@ def self.supported?
@_supported
end
+ def self.version_at_least?(version)
+ if @_version.nil?
+ output = BigTuna::Runner.execute(Dir.pwd, "git --version").stdout.first
+ @_version = output.match(/\d+\.\d+\.\d+/)[0].split(".").map { |e| e.to_i }
+ end
+ parts = version.split(".").map { |e| e.to_i }
+ parts.each_with_index do |part, index|
+ if part > @_version[index]
+ return false
+ elsif part < @_version[index]
+ return true
+ end
+ end
+ return true
+ end
+
def head_info
info = {}
command = "git log --max-count=1 --format=\"%H%n%an%n%ae%n%ad%n%s\" #{self.branch}"
@@ -31,7 +47,11 @@ def head_info
end
def clone(where_to)
- command = "git clone --branch #{self.branch} --depth 1 #{self.source} #{where_to}"
+ if self.class.version_at_least?("1.6.5")
+ command = "git clone --branch #{self.branch} --depth 1 #{self.source} #{where_to}"
+ else
+ command = "mkdir -p #{where_to} && cd #{where_to} && git init && git pull #{self.source} #{self.branch} && git branch -M master #{self.branch}"
+ end
BigTuna::Runner.execute(Dir.pwd, command)
end
end

0 comments on commit e74fd7f

Please sign in to comment.