Skip to content

Commit 47823f0

Browse files
committed
feat: only generate baseline if it hasn't already been generated
1 parent 2b21409 commit 47823f0

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

exe/codeclimate_diff

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ OptionParser.new do |opts|
2323
"Grep pattern to filter files. If provided, will filter the files changed on your branch further.")
2424
end.parse!(into: options)
2525

26-
if options[:baseline]
27-
CodeclimateDiff::Runner.generate_baseline
28-
elsif options[:"new-only"]
29-
CodeclimateDiff::Runner.run_diff_on_branch(options[:pattern], always_analyze_all_files: options[:all], show_preexisting: false)
26+
if options[:"new-only"]
27+
CodeclimateDiff::Runner.run_diff_on_branch(options[:pattern], always_analyze_all_files: options[:all],
28+
show_preexisting: false)
3029
else
31-
CodeclimateDiff::Runner.run_diff_on_branch(options[:pattern], always_analyze_all_files: options[:all], show_preexisting: true)
30+
CodeclimateDiff::Runner.run_diff_on_branch(options[:pattern], always_analyze_all_files: options[:all],
31+
show_preexisting: true)
3232
end

lib/codeclimate_diff/runner.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def self.setup_baseline_for_branch
9595
system("git worktree add ../temp-codeclimate #{main_branch}")
9696

9797
Dir.chdir("../temp-codeclimate") do
98-
# Execute shell command in the '../temp-codeclimate' directory
9998
generate_baseline
10099

101100
puts "Copying the baseline to #{project_repo}..."
@@ -107,8 +106,7 @@ def self.setup_baseline_for_branch
107106
end
108107

109108
def self.run_diff_on_branch(pattern, always_analyze_all_files: false, show_preexisting: true)
110-
# CodeclimateWrapper.new.pull_latest_image
111-
setup_baseline_for_branch
109+
setup_baseline_for_branch unless File.exist?("codeclimate_diff_baseline.json")
112110

113111
changed_filenames = calculate_changed_filenames(pattern)
114112

0 commit comments

Comments
 (0)