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



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

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)


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

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

#revisionObject



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

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



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

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

  run_command(command, chdir: @target)
end