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



513
514
515
516
517
518
519
520
521
# File 'lib/puppet_fixtures.rb', line 513

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)


541
542
543
# File 'lib/puppet_fixtures.rb', line 541

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

#revisionObject



531
532
533
534
535
536
537
538
539
# File 'lib/puppet_fixtures.rb', line 531

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



523
524
525
526
527
528
529
# File 'lib/puppet_fixtures.rb', line 523

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

  run_command(command, chdir: @target)
end