Sha256: bba9f832c88e3c428e942c37100ca5c2a8295962739d37fb6af361e276ce2ec3

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 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
  # Default git wrapper without configuration
  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

5 entries across 5 versions & 1 rubygems

Version Path
codeowners-checker-1.0.5 lib/codeowners/config.rb
codeowners-checker-1.0.4 lib/codeowners/config.rb
codeowners-checker-1.0.3 lib/codeowners/config.rb
codeowners-checker-1.0.2 lib/codeowners/config.rb
codeowners-checker-1.0.1 lib/codeowners/config.rb