Sha256: 431b85cf1fa90e031e541e5446359c9cd1c061a4f25a0b36ffadc75c2aa2cda1

Contents?: true

Size: 1.96 KB

Versions: 197

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

require 'avm/tools/core_ext'
require 'avm/git/revision_test'

module Avm
  module Tools
    class Runner
      class Git
        class RevisionsTest
          runner_with :help do
            desc 'Test multiple revisions until a error is found.'
            arg_opt '-c', '--command', 'Command to test instance.'
            bool_opt '-n', '--no-cache', 'Does not use cache.'
          end

          def run
            fatal_error('Repository is dirty') if runner_context.call(:git).dirty?

            return_to_branch_on_end do
              infov 'Revisions found', revisions.count
              if revision_with_error
                warn("First revision with error: #{revision_with_error}")
              else
                success('No error found in revisions')
              end
            end
          end

          private

          def return_to_branch_on_end
            current_branch = runner_context.call(:git).current_branch
            yield
          ensure
            infom "Returning to original branch \"#{current_branch}\""
            runner_context.call(:git).execute!('checkout', current_branch)
          end

          def revision_with_error_uncached
            revision_with_error = nil
            revisions.each do |revision|
              revision.banner
              unless revision.successful?
                revision_with_error = revision
                break
              end
            end
            revision_with_error
          end

          def revisions_uncached
            runner_context.call(:git).execute!('log', '--pretty=format:%H', 'origin/master..HEAD')
              .each_line.map(&:strip).reverse.map do |sha1|
              ::Avm::Git::RevisionTest.new(runner_context.call(:git), sha1, test_revision_options)
            end
          end

          def test_revision_options
            { test_command: parsed.command, no_cache: parsed.no_cache? }
          end
        end
      end
    end
  end
end

Version data entries

197 entries across 197 versions & 2 rubygems

Version Path
avm-tools-0.160.2 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.86.4 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.86.3 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
avm-tools-0.160.1 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.86.2 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.86.1 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
avm-tools-0.160.0 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.86.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.85.1 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
avm-tools-0.159.1 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.85.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.84.2 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.84.1 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.84.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.83.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
avm-tools-0.159.0 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.82.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
avm-tools-0.158.0 lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.81.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb
eac_tools-0.80.0 sub/avm-tools/lib/avm/tools/runner/git/revisions_test.rb