Skip to content

Commit

Permalink
Clone support for git < 1.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bugno committed Dec 12, 2010
1 parent a8703f5 commit e74fd7f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion extras/big_tuna/vcs/git.rb
Expand Up @@ -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}"
Expand All @@ -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
Expand Down

0 comments on commit e74fd7f

Please sign in to comment.