Sha256: 17db926c2c23f41e51da11a204fcd414f5a2b4cbb17a75e3fd727a5d3a8391fd

Contents?: true

Size: 918 Bytes

Versions: 3

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

require_relative 'interactive_resolver'
require_relative 'interactive_ops'

module Codeowners
  module Cli
    # Interactive session to resolve codeowners list issues
    class InteractiveRunner
      include InteractiveOps

      attr_writer :validate_owners, :default_owner, :autocommit

      def run_with(checker)
        resolver = InteractiveResolver.new(checker, @validate_owners, @default_owner)
        checker.fix!.each do |(error_type, inconsistencies, meta)|
          resolver.handle(error_type, inconsistencies, meta)
        end
        resolver.print_epilogue
        return unless resolver.made_changes?

        write_changes(checker)
        checker.commit_changes! if @autocommit || yes?('Commit changes?')
      end

      private

      def write_changes(checker)
        checker.codeowners.persist!
        checker.owners_list.persist!
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codeowners-checker-1.1.2 lib/codeowners/cli/interactive_runner.rb
codeowners-checker-1.1.1 lib/codeowners/cli/interactive_runner.rb
codeowners-checker-1.0.5 lib/codeowners/cli/interactive_runner.rb