Skip to content

Commit 2b21409

Browse files
committed
feat: set up automated baseline generation
1 parent 32e3101 commit 2b21409

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/codeclimate_diff/runner.rb

+22-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,29 @@ def self.generate_baseline
8686
puts "Done!"
8787
end
8888

89+
def self.setup_baseline_for_branch
90+
main_branch = CodeclimateDiff.configuration["main_branch_name"] || "main"
91+
92+
project_repo = `basename $(pwd)`.strip
93+
94+
puts "Creating a temp worktree to generate the baseline..."
95+
system("git worktree add ../temp-codeclimate #{main_branch}")
96+
97+
Dir.chdir("../temp-codeclimate") do
98+
# Execute shell command in the '../temp-codeclimate' directory
99+
generate_baseline
100+
101+
puts "Copying the baseline to #{project_repo}..."
102+
system("cp codeclimate_diff_baseline.json ../#{project_repo}")
103+
end
104+
105+
puts("Removing the temp worktree...")
106+
system("git worktree remove ../temp-codeclimate")
107+
end
108+
89109
def self.run_diff_on_branch(pattern, always_analyze_all_files: false, show_preexisting: true)
90-
CodeclimateWrapper.new.pull_latest_image
110+
# CodeclimateWrapper.new.pull_latest_image
111+
setup_baseline_for_branch
91112

92113
changed_filenames = calculate_changed_filenames(pattern)
93114

0 commit comments

Comments
 (0)