module R10K::Git

Constants

NULL_PROVIDER

Mark the current provider as invalid.

If a provider is set to an invalid provider, we need to make sure that the provider doesn't fall back to the default value, thereby ignoring the explicit value and silently continuing. If the current provider is assigned to this value, no provider will be used until the provider is either reset or assigned a valid provider.

@api private

UNSET_PROVIDER

Mark the current provider as unset.

If the provider has never been set we need to indicate that there is no current value but the default value can be used. If the current provider is assigned to this value and the provider is looked up, the default provider will be looked up and used.

@api private

Public Class Methods

bare_repository() click to toggle source
# File lib/r10k/git.rb, line 116
def self.bare_repository
  provider::BareRepository
end
cache() click to toggle source
# File lib/r10k/git.rb, line 112
def self.cache
  provider::Cache
end
default_name() click to toggle source

Return the first available Git provider.

@raise [R10K::Error] if no Git providers are functional. @return [String] The name of the first available Git implementation.

# File lib/r10k/git.rb, line 64
def self.default_name
  name, _ = @providers.find { |(_, hash)| R10K::Features.available?(hash[:feature]) }
  if name.nil?
    raise R10K::Error, "No Git providers are functional."
  end
  name
end
get_repo_settings(remote) click to toggle source
# File lib/r10k/git.rb, line 139
def self.get_repo_settings(remote)
  self.settings[:repositories].find {|r| r[:remote] == remote }
end
provider() click to toggle source

@return [Module] The namespace of the first available Git implementation.

Implementation classes should be looked up against this returned Module.
# File lib/r10k/git.rb, line 100
def self.provider
  case @provider
  when NULL_PROVIDER
    raise R10K::Error, "No Git provider set."
  when UNSET_PROVIDER
    self.provider = default_name
    logger.debug1 { "Setting Git provider to default provider #{default_name}" }
  end

  @provider
end
provider=(name) click to toggle source

Manually set the Git provider by name.

@param name [Symbol] The name of the Git provider to use. @raise [R10K::Error] if the requested Git provider doesn't exist. @raise [R10K::Error] if the requested Git provider isn't functional. @return [void]

# File lib/r10k/git.rb, line 80
def self.provider=(name)
  _, attrs = @providers.find { |(providername, _)| name == providername }
  if attrs.nil?
    @provider = NULL_PROVIDER
    raise R10K::Error, "No Git provider named '#{name}'."
  end
  if !R10K::Features.available?(attrs[:feature])
    @provider = NULL_PROVIDER
    raise R10K::Error, "Git provider '#{name}' is not functional."
  end
  if attrs[:on_set]
    attrs[:on_set].call
  end

  @provider = attrs[:module]
  logger.debug1 { "Setting Git provider to #{@provider.name}" }
end
reset!() click to toggle source

Clear the currently set provider.

@api private

# File lib/r10k/git.rb, line 127
def self.reset!
  @provider = UNSET_PROVIDER
end
thin_repository() click to toggle source
# File lib/r10k/git.rb, line 120
def self.thin_repository
  provider::ThinRepository
end