class Builderator::Tasks::Vendor
Tasks
to fetch and clean up remote artifacts
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 15 def self.exit_on_failure? true end
Public Instance Methods
_fetch_git(path, params)
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 55 def _fetch_git(path, params) ## Ensure that there isn't already something there unless path.join('.git').exist? remove_dir path empty_directory path end inside path do ## Initialize new repository unless path.join('.git').exist? run 'git init' run "git remote add #{ params.fetch(:remote, 'origin') } #{ params.git }" end run "git fetch #{ params.fetch(:remote, 'origin') } --tags --prune" ## Checkout reference if params.has?(:tag) then run "git checkout #{ params.tag }" elsif params.has?(:ref) then run "git checkout #{ params.ref }" else ## specified branch or master run "git checkout #{ params.fetch(:branch, 'master') }" ## Only pull if a tracking branch is checked out run "git pull #{ params.fetch(:remote, 'origin') } #{ params.fetch(:branch, 'master') }" end ## Apply relative subdirectory run "git filter-branch --subdirectory-filter \"#{ params.rel }\" --force" if params.has?(:rel) ## Update Submodules if path.join('.gitmodules').exist? run "git submodule update --init --recursive" end end end
_fetch_github(path, params)
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 91 def _fetch_github(path, params) params.git = "git@github.com:#{ params.github }.git" _fetch_git(path, params) end
_fetch_path(path, params)
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 96 def _fetch_path(path, params) remove_dir path.to_s if path.exist? create_link path.to_s, params.path.to_s end
all()
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 20 def all Config.vendor.each { |name, _| fetch(name) } end
clean(name = nil)
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 25 def clean(name = nil) ## Clean up all vendors return Config.vendor.each { |n, _| clean(n) } if name.nil? remove_dir Util.vendor(name) end
fetch(name = :default)
click to toggle source
# File lib/builderator/tasks/vendor.rb, line 33 def fetch(name = :default) empty_directory Util::VENDOR path = Util.vendor(name) params = Config.vendor(name) if params.has?(:github) say_status :vendor, "#{ name } from GitHub repository #{ params.github }" _fetch_github(path, params) elsif params.has?(:git) say_status :vendor, "#{ name } from git repository #{ params.git }" _fetch_git(path, params) elsif params.has?(:path) say_status :vendor, "#{ name } from path #{ params.path }" _fetch_path(path, params) end ## Include any policies embedded in this vendor Config.recompile end