class GitProc::GitConfig

Provides Git configuration

Public Class Methods

new(lib) click to toggle source
# File lib/git-process/git_config.rb, line 45
def initialize(lib)
  @lib = lib
end

Public Instance Methods

[](key) click to toggle source

@param key [String] the key for the Git configuration, as would be passed to ‘git config –get` @return [String] the value of the configuration; nil if not found

# File lib/git-process/git_config.rb, line 52
def [](key)
  value = config_hash[key]
  unless value
    value = gitlib.command(:config, ['--get', key])
    value = nil if value.empty?
    config_hash[key] = value unless config_hash.empty?
  end
  value
end
[]=(key, value) click to toggle source

Sets to configuration value for this repository.

@param key [String] the key for the Git configuration @param value [String] the value for the local configuration

@return [String] the value

# File lib/git-process/git_config.rb, line 69
def []=(key, value)
  gitlib.command(:config, [key, value])
  config_hash[key] = value unless config_hash.empty?
  value
end
default_rebase_sync(re, global = true) click to toggle source
# File lib/git-process/git_config.rb, line 101
def default_rebase_sync(re, global = true)
  if global
    set_global('gitProcess.defaultRebaseSync', re)
  else
    self['gitProcess.defaultRebaseSync'] = re
  end
end
default_rebase_sync=(re) click to toggle source
# File lib/git-process/git_config.rb, line 110
def default_rebase_sync=(re)
  default_rebase_sync(re, false)
end
default_rebase_sync?() click to toggle source

@return [Boolean] true if no value has been set; the value of the config otherwise

# File lib/git-process/git_config.rb, line 95
def default_rebase_sync?
  val = self['gitProcess.defaultRebaseSync']
  val.nil? or val.to_boolean
end
gitlib() click to toggle source

@return [GitLib] the GitLib this was initialized with

# File lib/git-process/git_config.rb, line 84
def gitlib
  @lib
end
integration_branch() click to toggle source
# File lib/git-process/git_config.rb, line 127
def integration_branch
  remote.exists? ? remote.master_branch_name : self.master_branch
end
logger() click to toggle source
# File lib/git-process/git_config.rb, line 89
def logger
  gitlib.logger
end
master_branch() click to toggle source

@return [String] the name of the integration branch; defaults to ‘master’

# File lib/git-process/git_config.rb, line 116
def master_branch
  @master_branch ||= self['gitProcess.integrationBranch'] || 'master'
end
remote_master_branch() click to toggle source

@deprecated use {GitProc::GitRemote#master_branch_name} instead

# File lib/git-process/git_config.rb, line 122
def remote_master_branch
  remote.master_branch_name
end
set_global(key, value) click to toggle source
# File lib/git-process/git_config.rb, line 76
def set_global(key, value)
  gitlib.command(:config, ['--global', key, value])
  config_hash[key] = value unless config_hash.empty?
  value
end

Private Instance Methods

config_hash() click to toggle source
# File lib/git-process/git_config.rb, line 139
def config_hash
  @config_hash ||= {}
end
remote() click to toggle source
# File lib/git-process/git_config.rb, line 134
def remote
  gitlib.remote
end