11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/lapidarist/cli.rb', line 11
def run
Options.new(args).parse
Lapidarist.logger.('Starting lapidarist')
trap_interrupt
unless git.clean?
Lapidarist.logger.('stopping, there are uncommitted changes')
return STATUS_ERROR
end
sha.record_good
gems = Lapidarist::Outdated.new.run
status = nil
attempt = 0
loop do
attempt += 1
Lapidarist.logger.("Attempt ##{attempt}")
if gems.outdated.none?
Lapidarist.logger.('stopping, there are no applicable outdated gems')
status = Status.new(gems, attempt)
break
end
updated_gems = update.run(gems, attempt)
if sha.new_commit_count.zero?
Lapidarist.logger.('nothing updated, trying again')
gems = gems.merge(updated_gems)
next
end
Lapidarist.logger.("Testing gem updates")
if test.success?
Lapidarist.logger.('test passed, nothing left to do')
gems = gems.merge(updated_gems)
status = Status.new(gems, attempt)
break
else
Lapidarist.logger.('test failed')
end
failed_gem = Lapidarist::FindFailure.new(
gems: updated_gems,
attempt: attempt,
last_good_sha: sha.last_good
).run
gems = gems.merge(updated_gems.take(sha.new_commit_count)).merge(failed_gem)
sha.record_good
if Lapidarist.config.debug
Summary.new(gems).display_debug
end
end
Summary.new(gems).display
return status.to_i
rescue OptionParser::InvalidOption => e
warn e.message
warn 'For usage information, use --help'
return STATUS_ERROR
rescue Lapidarist::Abort => e
git.reset_hard(sha.last_good)
Summary.new(gems).display
return STATUS_ERROR
end
|