module Aid::GitConfig

Public Instance Methods

git_config(key, value = nil) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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