Class: Gitt::Commands::Config
- Inherits:
-
Object
- Object
- Gitt::Commands::Config
- Defined in:
- lib/gitt/commands/config.rb
Overview
A Git config command wrapper.
Instance Method Summary collapse
- #call ⇒ Object
- #get(key, fallback = Core::EMPTY_STRING) ⇒ Object
-
#initialize(shell: SHELL) ⇒ Config
constructor
A new instance of Config.
- #origin? ⇒ Boolean
- #set(key, value) ⇒ Object
Constructor Details
Instance Method Details
#call ⇒ Object
16 |
# File 'lib/gitt/commands/config.rb', line 16 def call(*) = shell.call("config", *) |
#get(key, fallback = Core::EMPTY_STRING) ⇒ Object
18 19 20 21 |
# File 'lib/gitt/commands/config.rb', line 18 def get(key, fallback = Core::EMPTY_STRING, *) call(*, "--get", key).fmap(&:chomp) .or { |error| block_given? ? yield(error) : Success(fallback) } end |
#origin? ⇒ Boolean
23 |
# File 'lib/gitt/commands/config.rb', line 23 def origin? = !get("remote.origin.url").value_or(Core::EMPTY_STRING).empty? |
#set(key, value) ⇒ Object
25 |
# File 'lib/gitt/commands/config.rb', line 25 def set(key, value, *) = call(*, "--add", key, value).fmap { value } |