@@ -313,17 +313,16 @@ def download_files(self, file_paths):
313313 base_clone_dir = os .path .join (self .temp_dir , 'base_repo' )
314314 token = self .headers ['Authorization' ].replace ('token ' ,'' )
315315 auth_clone_url = f"https://x-access-token:{ token } @{ GHES_URL .replace ('https://' ,'' )} /{ self .repo_full_name } .git"
316- clone_res = subprocess .run (['git' ,'clone' ,'--depth' ,'1' ,'--branch' , self .pr_data ['base' ]['ref' ], auth_clone_url , base_clone_dir ], capture_output = True , text = True , timeout = 60 )
316+ # Calculate date 30 days ago for consistent shallow clone across environments
317+ from datetime import datetime , timedelta
318+ thirty_days_ago = (datetime .now () - timedelta (days = 30 )).strftime ('%Y-%m-%d' )
319+ clone_res = subprocess .run (['git' ,'clone' ,'--shallow-since' , thirty_days_ago ,'--branch' , self .pr_data ['base' ]['ref' ], auth_clone_url , base_clone_dir ], capture_output = True , text = True , timeout = 60 )
317320 if clone_res .returncode != 0 :
318321 raise Exception (f"Git clone failed: { clone_res .stderr } " )
319- # First try apply with whitespace fix, then 3way for modifications
320- normal_apply_res = subprocess .run (['git' ,'apply' ,'--whitespace=fix' , diff_path ], cwd = base_clone_dir , capture_output = True , text = True , timeout = 30 )
321- if normal_apply_res .returncode != 0 :
322- logger .info (f"Git apply failed, trying --3way: { normal_apply_res .stderr [:200 ]} " )
323- threeway_apply_res = subprocess .run (['git' ,'apply' ,'--3way' ,'--ignore-whitespace' , diff_path ], cwd = base_clone_dir , capture_output = True , text = True , timeout = 30 )
324- apply_res = threeway_apply_res
325- else :
326- apply_res = normal_apply_res
322+ # Apply diff with 3-way merge and whitespace fix
323+ apply_res = subprocess .run (['git' ,'apply' ,'--3way' ,'--whitespace=fix' , diff_path ], cwd = base_clone_dir , capture_output = True , text = True , timeout = 30 )
324+ if apply_res .returncode != 0 :
325+ logger .warning (f"Git apply failed: { apply_res .stderr [:500 ]} " )
327326 stderr_lower = apply_res .stderr .lower ()
328327 applied_some = stderr_lower .count ('applied patch' ) + stderr_lower .count ('cleanly' )
329328 self .diff_applied = apply_res .returncode == 0 or applied_some > 0
0 commit comments