b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornbergermodule GitRepository::Config
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger protected
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
c00d76f9bce28fe681b17235609953424ac021e5Julian Kornberger def get_config(key)
c00d76f9bce28fe681b17235609953424ac021e5Julian Kornberger git_exec 'config', key
c00d76f9bce28fe681b17235609953424ac021e5Julian Kornberger end
c00d76f9bce28fe681b17235609953424ac021e5Julian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger def set_section(section, options)
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger section = Array.wrap(section)
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger remove_section section
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger add_section section, options
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger end
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger def add_section(section, options)
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger mainsection, subsection = *section
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger File.open("#{local_path}/config","a") do |f|
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger f.puts "[#{mainsection}" << (subsection ? " \"#{subsection}\"" : '') << "]"
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger options.each do |key,value|
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger f.puts "\t#{key} = #{value}"
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger end
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger end
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger end
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger # Removes a config section
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger def remove_section(section)
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger git_exec 'config', '--remove-section', section.join(".")
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger true
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger rescue Exception => e
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger raise unless e.message.include?('No such section')
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger false
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger end
b66a6512eb6dea6cf5339eaa857a81d1b89cb4deJulian Kornberger
ee5342a8882c2fc7631fcffb5497e6597747887cTim Reddehaseend