Class: VagrantPlugins::VagrantGit::Action::HandleRepos
- Inherits:
-
Object
- Object
- VagrantPlugins::VagrantGit::Action::HandleRepos
- Defined in:
- lib/vagrant-git/action.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ HandleRepos
constructor
A new instance of HandleRepos.
Constructor Details
#initialize(app, env) ⇒ HandleRepos
Returns a new instance of HandleRepos.
7 8 9 10 |
# File 'lib/vagrant-git/action.rb', line 7 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/vagrant-git/action.rb', line 12 def call(env) @app.call(env) @env = env @vm = env[:machine] errors = {} @vm.config.git.to_hash[:repos].each do |rc| errors[rc.path] = [] if not rc.clone_in_host raise 'NotImplemented: clone_in_host=>false' end if File.exist? "#{rc.path}/.git" if rc.sync_on_load Git::fetch(rc.path) Git::pull(rc.path, {:branch => rc.branch}) end else p = Git::clone(rc.target, rc.path, {:branch => rc.branch}) if p.success? and rc.set_upstream @vm.ui.info("Clone done - setting upstream of #{rc.path} to #{rc.set_upstream}") if not Git::set_upstream(rc.path, rc.set_upstream).success? err = "Failed to change upstream to #{rc.set_upstream} in #{rc.path}" errors[rc.path].push(err) @vm.ui.error(err) end elsif !p.success? err = "Failed to clone #{rc.target} into #{rc.path}" errors[rc.path].push(err) @vm.ui.error(err) end if File.exist? "#{rc.path}/.gitmodules" p = Git::submodule(rc.path) if p.success? @vm.ui.info("Checked out submodules.") else err ="WARNING: Failed to check out submodules for #{rc.path}" errors[rc.path].push(err) @vm.ui.error(err) end end end end # Reprint any errors errors = errors.reject { |k, v| v.length == 0 } if errors.length > 0 @vm.ui.error("WARNING: Encountered errors when cloning repos.") errors.each do |repo, errs| @vm.ui.error("-- #{repo} --") errs.each do |e| @vm.ui.error(e) end end @vm.ui.error("If these were due to transient network issues, try again with:") @vm.ui.error("\tvagrant halt") @vm.ui.error("\tvagrant up") end end |