From 6e31c88b954c11c0c66789c7724eca12abd20088 Mon Sep 17 00:00:00 2001 From: Benjamin Wood Date: Fri, 10 Nov 2023 22:51:38 +0000 Subject: [PATCH 1/2] Fix modified test files During development we were using changes from the working tree. Now that we are moving into alpha, we need to use the target branch. Co-authored-by: Nate Vick --- lib/selective/ruby/core/controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/selective/ruby/core/controller.rb b/lib/selective/ruby/core/controller.rb index 30d3e8e..851dabb 100644 --- a/lib/selective/ruby/core/controller.rb +++ b/lib/selective/ruby/core/controller.rb @@ -121,8 +121,10 @@ def transport_url end def build_env - result = `#{Pathname.new(__dir__) + BUILD_ENV_SCRIPT_PATH}` - JSON.parse(result) + @build_env ||= begin + result = `#{Pathname.new(__dir__) + BUILD_ENV_SCRIPT_PATH}` + JSON.parse(result) + end end def spawn_transport_process(url) @@ -237,8 +239,10 @@ def handle_remove_failed_test_case_result(test_case_id) end def modified_test_files - # Todo: This should find files changed in the current branch - `git diff --name-only`.split("\n").filter do |f| + target_branch = build_env["target_branch"] + return [] unless target_branch + + `git diff #{target_branch} --name-only`.split("\n").filter do |f| f.match?(/^#{runner.base_test_path}/) end end From 181d13222f526aca3966319999e8a3723251d78d Mon Sep 17 00:00:00 2001 From: Benjamin Wood Date: Fri, 10 Nov 2023 23:03:39 +0000 Subject: [PATCH 2/2] Ensure target_branch is a non-empty string Co-authored-by: Nate Vick --- lib/selective/ruby/core/controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/selective/ruby/core/controller.rb b/lib/selective/ruby/core/controller.rb index 851dabb..3514e90 100644 --- a/lib/selective/ruby/core/controller.rb +++ b/lib/selective/ruby/core/controller.rb @@ -240,7 +240,7 @@ def handle_remove_failed_test_case_result(test_case_id) def modified_test_files target_branch = build_env["target_branch"] - return [] unless target_branch + return [] if target_branch.nil? || target_branch.empty? `git diff #{target_branch} --name-only`.split("\n").filter do |f| f.match?(/^#{runner.base_test_path}/)