From 11d2ed5e4a40d7d68a8b9fabcf0631486301fdf8 Mon Sep 17 00:00:00 2001 From: Sameera Priyatham Tadikonda Date: Thu, 22 Jan 2026 09:31:04 -0800 Subject: [PATCH 1/2] PDP-919: Fix the merge issue --- github-app/app.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/github-app/app.py b/github-app/app.py index db8afb8..fd5e479 100644 --- a/github-app/app.py +++ b/github-app/app.py @@ -282,10 +282,18 @@ def get_changed_files(self): raise Exception(f"Failed to get PR files: {resp.status_code}") changed = [] for fd in resp.json(): - if fd['status'] in ['added','modified']: - fn = fd['filename'] + status = fd['status'] + fn = fd['filename'] + # Skip deleted/removed files - they don't exist in PR head + if status in ['removed', 'deleted']: + logger.info(f"Skipping deleted file: {fn}") + continue + # For added, modified, or renamed files, use the new filename + if status in ['added', 'modified', 'renamed']: if not fn.startswith('.') or fn == '.copyrightconfig': changed.append(fn) + else: + logger.warning(f"Unknown file status '{status}' for {fn}") logger.info(f"Changed files: {len(changed)}") return changed except Exception as e: @@ -308,10 +316,16 @@ def download_files(self, file_paths): 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) if clone_res.returncode != 0: raise Exception(f"Git clone failed: {clone_res.stderr}") - apply_res = subprocess.run(['git','apply','--3way','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) + # First try normal apply for new files, then 3way for modifications + apply_res = subprocess.run(['git','apply','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) + if apply_res.returncode != 0: + logger.info(f"Normal git apply failed, trying --3way: {apply_res.stderr[:200]}") + apply_res = subprocess.run(['git','apply','--3way','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) 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 + if apply_res.returncode != 0: + logger.warning(f"Git apply stderr: {apply_res.stderr[:500]}") downloaded = [] diff_content = diff_resp.text for fp in file_paths: @@ -325,7 +339,7 @@ def download_files(self, file_paths): else: self.files_from_base.append(fp) else: - logger.warning(f"File not found: {fp}") + logger.warning(f"File not found after diff apply: {fp}") return downloaded except Exception as e: logger.error(f"download_files error: {e}") From 13d366dd47dfe5515fcf4d287e4a7fa3bfe6d63f Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 22 Jan 2026 09:34:27 -0800 Subject: [PATCH 2/2] Update github-app/app.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- github-app/app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/github-app/app.py b/github-app/app.py index fd5e479..08de1e5 100644 --- a/github-app/app.py +++ b/github-app/app.py @@ -317,10 +317,13 @@ def download_files(self, file_paths): if clone_res.returncode != 0: raise Exception(f"Git clone failed: {clone_res.stderr}") # First try normal apply for new files, then 3way for modifications - apply_res = subprocess.run(['git','apply','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) - if apply_res.returncode != 0: - logger.info(f"Normal git apply failed, trying --3way: {apply_res.stderr[:200]}") - apply_res = subprocess.run(['git','apply','--3way','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) + normal_apply_res = subprocess.run(['git','apply','--ignore-whitespace', diff_path], cwd=base_clone_dir, capture_output=True, text=True, timeout=30) + if normal_apply_res.returncode != 0: + logger.info(f"Normal 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 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