Sha256: f2b820a244f0c8593c9c49e9d1ba1409918d35016926d195daf3e25bd3b834a5

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

# frozen_string_literal: true

Git::Lib.class_eval do
  def config_set(name, value)
    command('config',  [name, value])
  rescue Git::GitExecuteError
    command('config',  ['--add', name, value])
  end

  def config_get(name)
    do_get = proc do |_path|
      command('config', ['--get', name])
    end

    if @git_dir
      Dir.chdir(@git_dir, &do_get)
    else
      do_get.call
    end
  end
end

module Codeowners
  class AnonymousGit
    include Git
  end

  # Connfigure and manage the git config file.
  class Config
    def initialize(git = AnonymousGit.new)
      @git = git
    end

    def default_owner
      @git.config('user.owner')
    end

    def default_owner=(name)
      @git.config('user.owner', name)
    end

    def to_h
      {
        default_owner: default_owner
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codeowners-checker-1.0.0 lib/codeowners/config.rb