Sha256: c83d2ee1611e6719f2faffc3ac3de4bd4c75166ec48acde4e61028507055bcac

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 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 full_names_for(superproject)
      list = `git config --get-all superproject.#{superproject}.repo`
      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]
      (value.nil? || value.empty?) && default ? default : value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-multi-6.0.0 lib/git/multi/config.rb
git-multi-5.0.0 lib/git/multi/config.rb