Class: Lapidarist::FindFailure

Inherits:
Object
  • Object
show all
Defined in:
lib/lapidarist/find_failure.rb

Instance Method Summary collapse

Constructor Details

#initialize(gems:, attempt:, last_good_sha:) ⇒ FindFailure

Returns a new instance of FindFailure.



3
4
5
6
7
8
9
# File 'lib/lapidarist/find_failure.rb', line 3

def initialize(gems:, attempt:, last_good_sha:)
  @gems = gems
  @attempt = attempt
  @last_good_sha = last_good_sha
  @git = GitCommand.new
  @test = TestCommand.new
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lapidarist/find_failure.rb', line 11

def run
  Lapidarist.logger.header('Investigating failure')

  updated_but_failed_gem =
    if gems.one?
      git.reset_hard('HEAD^')
      gems.first
    else
      failed_gem_name = git.bisect(last_good_sha, test)
      gems.detect { |gem| gem.name == failed_gem_name }
    end

  Gem.from(
    updated_but_failed_gem,
    attempt: attempt,
    status: :failed,
    updated_version: updated_but_failed_gem.latest_attempt.version
  )
end