Module: R10K::Git

Extended by:
Logging, Settings::Mixin::ClassMethods
Defined in:
lib/r10k/git.rb,
lib/r10k/git/errors.rb,
lib/r10k/git/rugged.rb,
lib/r10k/git/shellgit.rb

Defined Under Namespace

Modules: Rugged, ShellGit Classes: Alternates, Cache, GitError, StatefulRepository, UnresolvableRefError

Constant Summary collapse

NULL_PROVIDER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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.

Object.new
UNSET_PROVIDER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

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.

Object.new

Constants included from Logging

Logging::LOG_LEVELS

Class Method Summary collapse

Methods included from Logging

debug_formatter, default_formatter, default_outputter, logger, logger_name, parse_level

Methods included from Settings::Mixin::ClassMethods

def_setting_attr, defaults, inherited, settings

Class Method Details

.bare_repositoryObject



115
116
117
# File 'lib/r10k/git.rb', line 115

def self.bare_repository
  provider::BareRepository
end

.cacheObject



111
112
113
# File 'lib/r10k/git.rb', line 111

def self.cache
  provider::Cache
end

.default_nameString

Return the first available Git provider.

Returns:

  • (String)

    The name of the first available Git implementation.

Raises:

  • (R10K::Error)

    if no Git providers are functional.



63
64
65
66
67
68
69
# File 'lib/r10k/git.rb', line 63

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

.providerModule

Returns The namespace of the first available Git implementation. Implementation classes should be looked up against this returned Module.

Returns:

  • (Module)

    The namespace of the first available Git implementation. Implementation classes should be looked up against this returned Module.



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/r10k/git.rb', line 99

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) ⇒ void

This method returns an undefined value.

Manually set the Git provider by name.

Parameters:

  • name (Symbol)

    The name of the Git provider to use.

Raises:

  • (R10K::Error)

    if the requested Git provider doesn’t exist.

  • (R10K::Error)

    if the requested Git provider isn’t functional.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/r10k/git.rb', line 79

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!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Clear the currently set provider.



126
127
128
# File 'lib/r10k/git.rb', line 126

def self.reset!
  @provider = UNSET_PROVIDER
end

.thin_repositoryObject



119
120
121
# File 'lib/r10k/git.rb', line 119

def self.thin_repository
  provider::ThinRepository
end