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) ⇒ Object
- #[]=(key, value) ⇒ Object
- #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 ⇒ Object
-
#initialize(lib) ⇒ GitConfig
constructor
A new instance of GitConfig.
- #integration_branch ⇒ Object
- #logger ⇒ Object
- #master_branch ⇒ Object
- #remote_master_branch ⇒ Object
- #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) ⇒ 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.
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 |
#gitlib ⇒ Object
75 76 77 |
# File 'lib/git-process/git_config.rb', line 75 def gitlib @lib end |
#integration_branch ⇒ Object
117 118 119 |
# File 'lib/git-process/git_config.rb', line 117 def integration_branch remote.exists? ? remote_master_branch : self.master_branch end |
#logger ⇒ Object
80 81 82 |
# File 'lib/git-process/git_config.rb', line 80 def logger gitlib.logger end |
#master_branch ⇒ Object
107 108 109 |
# File 'lib/git-process/git_config.rb', line 107 def master_branch @master_branch ||= self['gitProcess.integrationBranch'] || 'master' end |
#remote_master_branch ⇒ Object
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 |