lib/spoom/cli/coverage.rb in spoom-1.1.12 vs lib/spoom/cli/coverage.rb in spoom-1.1.13
- old
+ new
@@ -44,11 +44,11 @@
in_sorbet_project!
path = exec_path
sorbet = options[:sorbet]
ref_before = Spoom::Git.current_branch
- ref_before = Spoom::Git.last_commit(path: path) unless ref_before
+ ref_before = Spoom::Git.last_commit(path: path)&.sha unless ref_before
unless ref_before
say_error("Not in a git repository")
say_error("\nSpoom needs to checkout into your previous commits to build the timeline.", status: nil)
exit(1)
end
@@ -69,33 +69,32 @@
from = parse_time(options[:from], "--from")
to = parse_time(options[:to], "--to")
unless from
- intro_sha = Spoom::Git.sorbet_intro_commit(path: path)
- intro_sha = T.must(intro_sha) # we know it's in there since in_sorbet_project!
- from = Spoom::Git.commit_time(intro_sha, path: path)
+ intro_commit = Spoom::Git.sorbet_intro_commit(path: path)
+ intro_commit = T.must(intro_commit) # we know it's in there since in_sorbet_project!
+ from = intro_commit.time
end
timeline = Spoom::Timeline.new(from, to, path: path)
ticks = timeline.ticks
if ticks.empty?
say_error("No commits to replay, try different `--from` and `--to` options")
exit(1)
end
- ticks.each_with_index do |sha, i|
- date = Spoom::Git.commit_time(sha, path: path)
- say("Analyzing commit `#{sha}` - #{date&.strftime("%F")} (#{i + 1} / #{ticks.size})")
+ ticks.each_with_index do |commit, i|
+ say("Analyzing commit `#{commit.sha}` - #{commit.time.strftime("%F")} (#{i + 1} / #{ticks.size})")
- Spoom::Git.checkout(sha, path: path)
+ Spoom::Git.checkout(commit.sha, path: path)
snapshot = T.let(nil, T.nilable(Spoom::Coverage::Snapshot))
if options[:bundle_install]
Bundler.with_unbundled_env do
- next unless bundle_install(path, sha)
+ next unless bundle_install(path, commit.sha)
snapshot = Spoom::Coverage.snapshot(path: path, sorbet_bin: sorbet)
end
else
snapshot = Spoom::Coverage.snapshot(path: path, sorbet_bin: sorbet)
@@ -105,11 +104,11 @@
snapshot.print(indent_level: 2)
say("\n")
next unless save_dir
- file = "#{save_dir}/#{sha}.json"
+ file = "#{save_dir}/#{commit.sha}.json"
File.write(file, snapshot.to_json)
say(" Snapshot data saved under `#{file}`\n\n")
end
Spoom::Git.checkout(ref_before, path: path)
end
@@ -146,10 +145,10 @@
palette = Spoom::Coverage::D3::ColorPalette.new(
ignore: options[:color_ignore],
false: options[:color_false],
true: options[:color_true],
strict: options[:color_strict],
- strong: options[:color_strong]
+ strong: options[:color_strong],
)
report = Spoom::Coverage.report(snapshots, palette: palette, path: exec_path)
file = options[:file]
File.write(file, report.html)