Sha256: 8bf8ec64412a0e47f62d11bf21d0a44a132dbbef6ba3154da5b94a2af9b2cda4

Contents?: true

Size: 1.31 KB

Versions: 156

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require 'avm/git/subrepo_check'
require 'eac_ruby_utils/core_ext'

module Avm
  module Git
    class SubrepoChecks
      enable_speaker
      enable_simple_cache
      attr_accessor :check_remote, :fix_parent
      common_constructor :repository

      def add_all_subrepos
        add_subrepos(
          *repository.command('subrepo', '-q', 'status').execute!.split("\n").map(&:strip)
          .select(&:present?)
        )
      end

      def add_subrepos(*subpath_list)
        subpath_list.each do |subpath|
          subpaths.add(subpath)
        end
        reset_cache
        self
      end

      def check_options
        { fix_parent: fix_parent, check_remote: check_remote }
      end

      def show_result
        checks.each(&:show_result)
        infov 'Result', result.label
      end

      private

      def checks_uncached
        subpaths.map do |subpath|
          ::Avm::Git::SubrepoCheck.new(repository.subrepo(subpath), check_options)
        end
      end

      def result_uncached
        error_count = checks.count { |check| check.result.error? }
        ::Avm::Result.success_or_error(
          error_count.zero?,
          "#{error_count} of #{checks.count} subrepos failed"
        )
      end

      def subpaths
        @subpaths ||= ::Set.new
      end
    end
  end
end

Version data entries

156 entries across 156 versions & 4 rubygems

Version Path
eac_tools-0.80.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.76.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.75.2 sub/avm-git/lib/avm/git/subrepo_checks.rb
avm-git-0.13.4 lib/avm/git/subrepo_checks.rb
eac_tools-0.75.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.75.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.74.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.74.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.73.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.72.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.70.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.70.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.69.1 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.69.0 sub/avm-git/lib/avm/git/subrepo_checks.rb
eac_tools-0.68.0 sub/avm-git/lib/avm/git/subrepo_checks.rb