Class: GitProc::GitConfig
- Inherits:
-
Object
- Object
- GitProc::GitConfig
- Defined in:
- lib/git-process/git_config.rb
Overview
Provides Git configuration
Instance Method Summary collapse
-
#[](key) ⇒ String
The value of the configuration; nil if not found.
-
#[]=(key, value) ⇒ String
Sets to configuration value for this repository.
- #default_rebase_sync(re, global = true) ⇒ Object
- #default_rebase_sync=(re) ⇒ Object
-
#default_rebase_sync? ⇒ Boolean
True if no value has been set; the value of the config otherwise.
-
#gitlib ⇒ GitLib
The GitLib this was initialized with.
-
#initialize(lib) ⇒ GitConfig
constructor
A new instance of GitConfig.
- #integration_branch ⇒ Object
- #logger ⇒ Object
-
#master_branch ⇒ String
The name of the integration branch; defaults to ‘master’.
-
#remote_master_branch ⇒ Object
deprecated
Deprecated.
use GitProc::GitRemote#master_branch_name instead
- #set_global(key, value) ⇒ Object
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) ⇒ String
Returns the value of the configuration; nil if not found.
52 53 54 55 56 57 58 59 60 |
# 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) ⇒ String
Sets to configuration value for this repository.
69 70 71 72 73 |
# 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) ⇒ Object
101 102 103 104 105 106 107 |
# 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) ⇒ Object
110 111 112 |
# File 'lib/git-process/git_config.rb', line 110 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.
95 96 97 98 |
# 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 ⇒ GitLib
Returns the GitLib this was initialized with.
84 85 86 |
# File 'lib/git-process/git_config.rb', line 84 def gitlib @lib end |
#integration_branch ⇒ Object
127 128 129 |
# File 'lib/git-process/git_config.rb', line 127 def integration_branch remote.exists? ? remote.master_branch_name : self.master_branch end |
#logger ⇒ Object
89 90 91 |
# File 'lib/git-process/git_config.rb', line 89 def logger gitlib.logger end |
#master_branch ⇒ String
Returns the name of the integration branch; defaults to ‘master’.
116 117 118 |
# File 'lib/git-process/git_config.rb', line 116 def master_branch @master_branch ||= self['gitProcess.integrationBranch'] || 'master' end |
#remote_master_branch ⇒ Object
Deprecated.
use GitProc::GitRemote#master_branch_name instead
122 123 124 |
# File 'lib/git-process/git_config.rb', line 122 def remote_master_branch remote.master_branch_name end |
#set_global(key, value) ⇒ Object
76 77 78 79 80 |
# 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 |