class MxxRu::Externals::Git
Attributes
commit[R]
commit=[R]
tag[R]
tag=[R]
Public Class Methods
new(name) { |self| ... }
click to toggle source
# File lib/mxx_ru/externals.rb, line 511 def initialize(name) defaults(name) @unlimited_depth = false @recursive = false yield self if block_given? raise "#{name}: tag and commit cannot be specified together" if @tag and @commit Registry::handle_external(@name, self) end
Public Instance Methods
define_rules(old_or_new)
click to toggle source
# File lib/mxx_ru/externals.rb, line 548 def define_rules(old_or_new) define(old_or_new) do |tmp_dir| if @commit.nil? # No specific commit. # Simple clone (probably with --depth 1) is enough. sh_args = ['git', 'clone'] sh_args << '--branch' << @tag.to_s if @tag sh_args << '--depth' << '1' unless @unlimited_depth sh_args << '--recursive' if @recursive push_options_to(sh_args) sh_args << @url << tmp_dir sh *sh_args else # To extract specific commit is necessary to do # at least two commands: clone (without limitiation of depth) and # checkout for specific commit. # Do `clone repo tmp_dir` sh *(push_options_to(['git', 'clone']).push(@url).push(tmp_dir)) # Do `checkout commit` inside tmp_dir cd tmp_dir do sh 'git', 'checkout', @commit end end end end
make_hash()
click to toggle source
# File lib/mxx_ru/externals.rb, line 539 def make_hash options_to_map.merge!( basics_to_map ).merge!( { :recursive => @recursive, :unlimited_depth => @unlimited_depth, :tag => @tag, :commit => @commit } ) end
recursive()
click to toggle source
# File lib/mxx_ru/externals.rb, line 531 def recursive @recursive = true end
unlimited_depth()
click to toggle source
# File lib/mxx_ru/externals.rb, line 527 def unlimited_depth @unlimited_depth = true end