Class: GitProc::GitConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/git-process/git_config.rb

Overview

Provides Git configuration

Instance Method Summary collapse

Constructor Details

#initialize(lib) ⇒ GitConfig

Returns a new instance of GitConfig.



45
46
47
# File 'lib/git-process/git_config.rb', line 45

def initialize(lib)
  @lib = lib
end

Instance Method Details

#[](key) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/git-process/git_config.rb', line 50

def [](key)
  value = config_hash[key]
  unless value
    value = @lib.command(:config, ['--get', key])
    value = nil if value.empty?
    config_hash[key] = value unless config_hash.empty?
  end
  value
end

#[]=(key, value) ⇒ Object



61
62
63
64
65
# File 'lib/git-process/git_config.rb', line 61

def []=(key, value)
  @lib.command(:config, [key, value])
  config_hash[key] = value unless config_hash.empty?
  value
end

#default_rebase_sync(re, global = true) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/git-process/git_config.rb', line 93

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



102
103
104
# File 'lib/git-process/git_config.rb', line 102

def default_rebase_sync=(re)
  default_rebase_sync(re, false)
end

#default_rebase_sync?Boolean

Returns true if no value has been set; the value of the config otherwise.

Returns:

  • (Boolean)

    true if no value has been set; the value of the config otherwise



87
88
89
90
# File 'lib/git-process/git_config.rb', line 87

def default_rebase_sync?
  val = self['gitProcess.defaultRebaseSync']
  val.nil? or val.to_boolean
end

#gitlibObject



75
76
77
# File 'lib/git-process/git_config.rb', line 75

def gitlib
  @lib
end

#integration_branchObject



117
118
119
# File 'lib/git-process/git_config.rb', line 117

def integration_branch
  remote.exists? ? remote_master_branch : self.master_branch
end

#loggerObject



80
81
82
# File 'lib/git-process/git_config.rb', line 80

def logger
  gitlib.logger
end

#master_branchObject



107
108
109
# File 'lib/git-process/git_config.rb', line 107

def master_branch
  @master_branch ||= self['gitProcess.integrationBranch'] || 'master'
end

#remote_master_branchObject



112
113
114
# File 'lib/git-process/git_config.rb', line 112

def remote_master_branch
  remote.master_branch_name
end

#set_global(key, value) ⇒ Object



68
69
70
71
72
# File 'lib/git-process/git_config.rb', line 68

def set_global(key, value)
  @lib.command(:config, ['--global', key, value])
  config_hash[key] = value unless config_hash.empty?
  value
end