Module: R10K::Git

Extended by:
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, Commit, GitError, Head, Ref, RemoteHead, Repository, StatefulRepository, Tag, UnresolvableRefError, WorkingDir

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

Class Method Summary collapse

Methods included from Settings::Mixin::ClassMethods

def_setting_attr, defaults, inherited, settings

Class Method Details

.bare_repositoryObject



88
89
90
# File 'lib/r10k/git.rb', line 88

def self.bare_repository
  provider::BareRepository
end

.cacheObject



84
85
86
# File 'lib/r10k/git.rb', line 84

def self.cache
  provider::Cache
end

.defaultModule

Return the first available Git provider.

Returns:

  • (Module)

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

Raises:

  • (R10K::Error)

    if no Git providers are functional.



44
45
46
47
48
49
50
# File 'lib/r10k/git.rb', line 44

def self.default
  _, attrs = @providers.find { |(_, hash)| R10K::Features.available?(hash[:feature]) }
  if attrs.nil?
    raise R10K::Error, "No Git providers are functional."
  end
  attrs[:module]
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.



73
74
75
76
77
78
79
80
81
82
# File 'lib/r10k/git.rb', line 73

def self.provider
  case @provider
  when NULL_PROVIDER
    raise R10K::Error, "No Git provider set."
  when UNSET_PROVIDER
    @provider = default
  else
    @provider
  end
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.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/r10k/git.rb', line 58

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
  @provider = attrs[:module]
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.



99
100
101
# File 'lib/r10k/git.rb', line 99

def self.reset!
  @provider = UNSET_PROVIDER
end

.thin_repositoryObject



92
93
94
# File 'lib/r10k/git.rb', line 92

def self.thin_repository
  provider::ThinRepository
end