Class: PuppetFixtures::Repository::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_fixtures.rb

Direct Known Subclasses

Git, Mercurial

Instance Method Summary collapse

Constructor Details

#initialize(remote:, target:, branch:, ref:) ⇒ Base

Returns a new instance of Base.



465
466
467
468
469
470
# File 'lib/puppet_fixtures.rb', line 465

def initialize(remote:, target:, branch:, ref:)
  @remote = remote
  @target = target
  @ref = ref
  @branch = branch
end

Instance Method Details

#download(flags = nil, subdir = nil) ⇒ Object



472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/puppet_fixtures.rb', line 472

def download(flags = nil, subdir = nil)
  can_update = false
  if File.directory?(@target)
    if remote_url_changed?
      warn "Remote for #{@target} has changed, recloning repository"
      FileUtils.rm_rf(@target)
    else
      can_update = true
    end
  end

  if can_update
    update
  else
    clone(flags)
    unless File.exist?(@target)
      raise "Failed to clone repository #{@remote} into #{@target}"
    end
  end

  revision
  remove_subdirectory(subdir) if subdir
end