Sha256: f4c7bba42439ae11cf4768ce2752c3ec06ab35bf12deb537f3eb51cd4ef159dd

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

module Git
  module Multi

    module_function

    def local_option(path, name, default = nil)
      value = `git -C #{path} config --local --get #{name}`.chomp.freeze
      value.empty? && default ? default : value
    end

    def local_list(filename, name)
      list = `git config --file #{filename} --get-all #{name}`
      list.split($RS).map(&:strip).map(&:freeze)
    end

    def global_option(name, default = nil)
      value = `git config --global --get #{name}`.chomp.freeze
      value.empty? && default ? default : value
    end

    def global_list(name, default = nil)
      global_option(name, default).split(',').map(&:strip).map(&:freeze)
    end

    def env_var(name, default = nil)
      value = ENV[name].dup.freeze
      (value.nil? || value.empty?) && default ? default : value
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-multi-2.1.0 lib/git/multi/config.rb