From 435a1442f18ad083eec564883c93d7d59bcb0b0f Mon Sep 17 00:00:00 2001 From: Sameera Priyatham Tadikonda Date: Thu, 22 Jan 2026 14:31:31 -0800 Subject: [PATCH 1/3] PDP-919: get old commits for merge --- github-app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-app/app.py b/github-app/app.py index 55f9273..69f8e4c 100644 --- a/github-app/app.py +++ b/github-app/app.py @@ -313,7 +313,7 @@ def download_files(self, file_paths): base_clone_dir = os.path.join(self.temp_dir, 'base_repo') token = self.headers['Authorization'].replace('token ','') auth_clone_url = f"https://x-access-token:{token}@{GHES_URL.replace('https://','')}/{self.repo_full_name}.git" - 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) + clone_res = subprocess.run(['git','clone','--shallow-since','1 month ago','--branch', self.pr_data['base']['ref'], auth_clone_url, base_clone_dir], capture_output=True, text=True, timeout=60) if clone_res.returncode != 0: raise Exception(f"Git clone failed: {clone_res.stderr}") # First try apply with whitespace fix, then 3way for modifications From acf5f2ff963d8082b2489f08afe59a689c5f0037 Mon Sep 17 00:00:00 2001 From: Sameera Priyatham Tadikonda Date: Thu, 22 Jan 2026 14:32:26 -0800 Subject: [PATCH 2/3] remove fallback logic --- github-app/app.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/github-app/app.py b/github-app/app.py index 69f8e4c..6ba5325 100644 --- a/github-app/app.py +++ b/github-app/app.py @@ -316,14 +316,10 @@ def download_files(self, file_paths): clone_res = subprocess.run(['git','clone','--shallow-since','1 month ago','--branch', self.pr_data['base']['ref'], auth_clone_url, base_clone_dir], capture_output=True, text=True, timeout=60) if clone_res.returncode != 0: raise Exception(f"Git clone failed: {clone_res.stderr}") - # First try apply with whitespace fix, then 3way for modifications - normal_apply_res = subprocess.run(['git','apply','--whitespace=fix', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) - if normal_apply_res.returncode != 0: - logger.info(f"Git apply failed, trying --3way: {normal_apply_res.stderr[:200]}") - threeway_apply_res = subprocess.run(['git','apply','--3way','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) - apply_res = threeway_apply_res - else: - apply_res = normal_apply_res + # Apply diff with 3-way merge and whitespace fix + apply_res = subprocess.run(['git','apply','--3way','--whitespace=fix', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) + if apply_res.returncode != 0: + logger.warning(f"Git apply failed: {apply_res.stderr[:500]}") stderr_lower = apply_res.stderr.lower() applied_some = stderr_lower.count('applied patch') + stderr_lower.count('cleanly') self.diff_applied = apply_res.returncode == 0 or applied_some > 0 From feb9e83e8d2d3a812b988e80482a2b0caa2e70a6 Mon Sep 17 00:00:00 2001 From: Sameera Priyatham Tadikonda Date: Thu, 22 Jan 2026 14:35:57 -0800 Subject: [PATCH 3/3] Add 30days --- github-app/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/github-app/app.py b/github-app/app.py index 6ba5325..6c2d7a6 100644 --- a/github-app/app.py +++ b/github-app/app.py @@ -313,7 +313,10 @@ def download_files(self, file_paths): base_clone_dir = os.path.join(self.temp_dir, 'base_repo') token = self.headers['Authorization'].replace('token ','') auth_clone_url = f"https://x-access-token:{token}@{GHES_URL.replace('https://','')}/{self.repo_full_name}.git" - clone_res = subprocess.run(['git','clone','--shallow-since','1 month ago','--branch', self.pr_data['base']['ref'], auth_clone_url, base_clone_dir], capture_output=True, text=True, timeout=60) + # Calculate date 30 days ago for consistent shallow clone across environments + from datetime import datetime, timedelta + thirty_days_ago = (datetime.now() - timedelta(days=30)).strftime('%Y-%m-%d') + 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) if clone_res.returncode != 0: raise Exception(f"Git clone failed: {clone_res.stderr}") # Apply diff with 3-way merge and whitespace fix