@@ -1189,7 +1189,9 @@ def process_review(
11891189 "coverage_message" : coverage_message ,
11901190 }
11911191
1192- if not self .args .no_pr and not self .args .staging_review :
1192+ raise_pr = not self .args .no_pr
1193+
1194+ if raise_pr and not self .args .staging_review :
11931195 data ["git_remote" ] = self .args .git_remote
11941196 check_create_pr (** data )
11951197 elif self .args .staging_review :
@@ -1200,12 +1202,24 @@ def process_review(
12001202 trace_id = self .function_trace_id , is_optimization_found = best_optimization is not None
12011203 )
12021204
1203- if ((not self .args .no_pr ) or not self .args .staging_review ) and (
1204- self .args .all or env_utils .get_pr_number () or (self .args .file and not self .args .function )
1205+ if raise_pr and (
1206+ self .args .all
1207+ or env_utils .get_pr_number ()
1208+ or self .args .replay_test
1209+ or (self .args .file and not self .args .function )
12051210 ):
1206- self .write_code_and_helpers (
1207- self .function_to_optimize_source_code , original_helper_code , self .function_to_optimize .file_path
1208- )
1211+ self .revert_code_and_helpers (original_helper_code )
1212+ return
1213+
1214+ if self .args .staging_review :
1215+ # always revert code and helpers when staging review
1216+ self .revert_code_and_helpers (original_helper_code )
1217+ return
1218+
1219+ def revert_code_and_helpers (self , original_helper_code : dict [Path , str ]) -> None :
1220+ self .write_code_and_helpers (
1221+ self .function_to_optimize_source_code , original_helper_code , self .function_to_optimize .file_path
1222+ )
12091223
12101224 def establish_original_code_baseline (
12111225 self ,
0 commit comments