diff --git a/lib/selective/ruby/core/controller.rb b/lib/selective/ruby/core/controller.rb index 30d3e8e..3514e90 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 [] if target_branch.nil? || target_branch.empty? + + `git diff #{target_branch} --name-only`.split("\n").filter do |f| f.match?(/^#{runner.base_test_path}/) end end