Sha256: 93fac678bbd1fea33fca2aea01500706ac453bb48b85669069d1d8632a18dddc
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
module GitReflow module Config extend self CONFIG_FILE_PATH = "$HOME/.gitconfig.reflow".freeze def get(key, reload: false, all: false, local: false) if reload == false and cached_key_value = instance_variable_get(:"@#{key.tr('.-', '_')}") cached_key_value else local = local ? '--local ' : '' if all new_value = GitReflow::Sandbox.run "git config #{local}--get-all #{key}", loud: false else new_value = GitReflow::Sandbox.run "git config #{local}--get #{key}", loud: false end instance_variable_set(:"@#{key.tr('.-', '_')}", new_value.strip) end end def set(key, value, local: false) value = value.strip if local GitReflow::Sandbox.run "git config --replace-all #{key} \"#{value}\"", loud: false else GitReflow::Sandbox.run "git config -f #{CONFIG_FILE_PATH} --replace-all #{key} \"#{value}\"", loud: false end end def unset(key, value: nil, local: false) value = (value.nil?) ? "" : "\"#{value}\"" if local GitReflow::Sandbox.run "git config --unset-all #{key} #{value}", loud: false else GitReflow::Sandbox.run "git config -f #{CONFIG_FILE_PATH} --unset-all #{key} #{value}", loud: false end end def add(key, value, local: false, global: false) if global GitReflow::Sandbox.run "git config --global --add #{key} \"#{value}\"", loud: false elsif local GitReflow::Sandbox.run "git config --add #{key} \"#{value}\"", loud: false else GitReflow::Sandbox.run "git config -f #{CONFIG_FILE_PATH} --add #{key} \"#{value}\"", loud: false end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
git_reflow-0.8.3 | lib/git_reflow/config.rb |
git_reflow-0.8.2 | lib/git_reflow/config.rb |