Skip to content

Commit eabcfa0

Browse files
committed
[CodeExtractor] checkout before build_prune_script
Prior, when doing `build_prune_script`, the branch was left at what ever state the previous step had left it at. However, this caused and issue when running `build_prune_script` as it was attempting to find the history for files that were just deleted in the `extract_branch` step (the branch that will be pushed to the `upstream_repo` that "deletes code"). This step ensures a `git checkout #{source_branch}` prior to building the script to ensure the files and their previous versions still exist. And additional tweak was also added to split up the initialization of the `file_and_ancestors` variable to make it easier to debug.
1 parent 73fd210 commit eabcfa0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/code_extractor.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def build_prune_script extractions
287287
prune_mvs = []
288288

289289
Dir.chdir git_dir do
290+
`git checkout #{source_branch}`
290291
extractions.each do |file_or_dir|
291292
if Dir.exist? file_or_dir
292293
files = Dir["#{file_or_dir}/**/*"]
@@ -295,7 +296,8 @@ def build_prune_script extractions
295296
end
296297

297298
files.each do |extraction_file|
298-
file_and_ancestors = `#{git_log_follow} -- #{extraction_file}`.split("\n").uniq
299+
raw_file_history = `#{git_log_follow} -- #{extraction_file}`
300+
file_and_ancestors = raw_file_history.split("\n").uniq
299301

300302
file_and_ancestors.reject! { |file| file.length == 0 }
301303

0 commit comments

Comments
 (0)