@@ -1242,7 +1242,9 @@ def process_review(
12421242 "concolic_tests" : concolic_tests ,
12431243 }
12441244
1245- if not self .args .no_pr and not self .args .staging_review :
1245+ raise_pr = not self .args .no_pr
1246+
1247+ if raise_pr and not self .args .staging_review :
12461248 data ["git_remote" ] = self .args .git_remote
12471249 check_create_pr (** data )
12481250 elif self .args .staging_review :
@@ -1253,12 +1255,24 @@ def process_review(
12531255 trace_id = self .function_trace_id , is_optimization_found = best_optimization is not None
12541256 )
12551257
1256- if ((not self .args .no_pr ) or not self .args .staging_review ) and (
1257- self .args .all or env_utils .get_pr_number () or (self .args .file and not self .args .function )
1258+ if raise_pr and (
1259+ self .args .all
1260+ or env_utils .get_pr_number ()
1261+ or self .args .replay_test
1262+ or (self .args .file and not self .args .function )
12581263 ):
1259- self .write_code_and_helpers (
1260- self .function_to_optimize_source_code , original_helper_code , self .function_to_optimize .file_path
1261- )
1264+ self .revert_code_and_helpers (original_helper_code )
1265+ return
1266+
1267+ if self .args .staging_review :
1268+ # always revert code and helpers when staging review
1269+ self .revert_code_and_helpers (original_helper_code )
1270+ return
1271+
1272+ def revert_code_and_helpers (self , original_helper_code : dict [Path , str ]) -> None :
1273+ self .write_code_and_helpers (
1274+ self .function_to_optimize_source_code , original_helper_code , self .function_to_optimize .file_path
1275+ )
12621276
12631277 def establish_original_code_baseline (
12641278 self ,
0 commit comments