Module: Aid::GitConfig
- Included in:
- Scripts::Begin, Scripts::Finish, Scripts::Review
- Defined in:
- lib/aid/scripts/shared/git_config.rb
Instance Method Summary collapse
- #git_config(key, value = nil) ⇒ Object
- #prompt(msg) ⇒ Object
- #prompt_for_config!(key, prompt_msg, remedy) ⇒ Object
Instance Method Details
#git_config(key, value = nil) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/aid/scripts/shared/git_config.rb', line 3 def git_config(key, value = nil) if value `git config --local --add #{key.inspect} #{value.inspect}` else git_value = `git config --get #{key.inspect}`.strip git_value.empty? ? nil : git_value end end |
#prompt(msg) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/aid/scripts/shared/git_config.rb', line 32 def prompt(msg) print "#{msg} > " value = STDIN.gets.strip puts value end |
#prompt_for_config!(key, prompt_msg, remedy) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aid/scripts/shared/git_config.rb', line 12 def prompt_for_config!(key, prompt_msg, remedy) value = git_config(key) if value == "" || value.nil? puts <<~EOF Missing git config "#{key}": To find this value: #{remedy} EOF new_value = prompt(prompt_msg) if new_value.empty? abort "Empty value, aborting" else git_config(key, new_value) end end end |