Class: PuppetFixtures::Repository::Git

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

Instance Method Summary collapse

Methods inherited from Base

#download, #initialize

Constructor Details

This class inherits a constructor from PuppetFixtures::Repository::Base

Instance Method Details

#clone(flags = nil) ⇒ Object



534
535
536
537
538
539
540
541
542
# File 'lib/puppet_fixtures.rb', line 534

def clone(flags = nil)
  command = %w[git clone]
  command.push('--depth', '1') unless @ref
  command.push('-b', @branch) if @branch
  command.push(flags) if flags
  command.push(@remote, @target)

  run_command(command)
end

#remote_url_changed?(remote = 'origin') ⇒ Boolean

Returns:

  • (Boolean)


562
563
564
# File 'lib/puppet_fixtures.rb', line 562

def remote_url_changed?(remote = 'origin')
  remote_url(remote) != @remote
end

#revisionObject



552
553
554
555
556
557
558
559
560
# File 'lib/puppet_fixtures.rb', line 552

def revision
  return true unless @ref

  command = ['git', 'reset', '--hard', @ref]
  result = run_command(command, chdir: @target)
  raise "Invalid ref #{@ref} for #{@target}" unless result

  result
end

#updateObject



544
545
546
547
548
549
550
# File 'lib/puppet_fixtures.rb', line 544

def update
  # TODO: should this pull?
  command = %w[git fetch]
  command.push('--unshallow') if shallow_git_repo?

  run_command(command, chdir: @target)
end