class R10K::Environment::Git

This class implements an environment based on a Git branch.

@since 1.3.0

Attributes

ref[R]

@!attribute [r] ref

@return [String] The git reference to use for this environment
remote[R]

@!attribute [r] remote

@return [String] The URL to the remote git repository
repo[R]

@!attribute [r] repo

@api private
@return [R10K::Git::StatefulRepository] The git repo backing this environment

Public Class Methods

new(name, basedir, dirname, options = {}) click to toggle source

Initialize the given Git environment.

@param name [String] The unique name describing this environment. @param basedir [String] The base directory where this environment will be created. @param dirname [String] The directory name for this environment. @param options [Hash] An additional set of options for this environment.

@param options [String] :remote The URL to the remote git repository @param options [String] :ref The git reference to use for this environment

Calls superclass method R10K::Environment::Base.new
# File lib/r10k/environment/git.rb, line 35
def initialize(name, basedir, dirname, options = {})
  super
  @remote = options[:remote]
  @ref    = options[:ref]

  @repo = R10K::Git::StatefulRepository.new(@remote, @basedir, @dirname)
end

Public Instance Methods

desired_contents() click to toggle source

Returns an array of the full paths to all the content being managed. @note This implements a required method for the Purgeable mixin @return [Array<String>]

# File lib/r10k/environment/git.rb, line 76
def desired_contents
  desired = [File.join(@full_path, '.git')]
  desired += @repo.tracked_paths.map { |entry| File.join(@full_path, entry) }
end
managed_directories() click to toggle source
# File lib/r10k/environment/git.rb, line 69
def managed_directories
  [@full_path]
end
signature() click to toggle source

Return a sting which uniquely identifies (per source) the current state of the environment.

@api public @return [String]

# File lib/r10k/environment/git.rb, line 63
def signature
  @repo.head
end
status() click to toggle source
# File lib/r10k/environment/git.rb, line 54
def status
  @repo.status(@ref)
end
sync() click to toggle source

Clone or update the given Git environment.

If the environment is being created for the first time, it will automatically update all modules to ensure that the environment is complete.

@api public @return [void]

# File lib/r10k/environment/git.rb, line 50
def sync
  @repo.sync(@ref)
end