From e0c995130888e3c95882850d11525d8ab5214ee0 Mon Sep 17 00:00:00 2001 From: m3taversal Date: Wed, 15 Apr 2026 17:15:58 +0100 Subject: [PATCH] fix: close stale PRs on Forgejo when pipeline DB marks them closed Two code paths set status='closed' in the pipeline DB without calling the Forgejo API to close the PR. This caused 50 ghost PRs to accumulate on Forgejo (dashboard shows review backlog) while the pipeline considered them done. - evaluate.py: no-diff stale branch close now calls Forgejo PATCH - merge.py: permanent conflict close now calls Forgejo PATCH Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/evaluate.py | 1 + lib/merge.py | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/evaluate.py b/lib/evaluate.py index 8251bbd..2595137 100644 --- a/lib/evaluate.py +++ b/lib/evaluate.py @@ -533,6 +533,7 @@ async def evaluate_pr(conn, pr_number: int, tier: str = None) -> dict: diff = await get_pr_diff(pr_number) if not diff: # Close PRs with no diff — stale branch, nothing to evaluate + await forgejo_api("PATCH", repo_path(f"pulls/{pr_number}"), {"state": "closed"}) conn.execute("UPDATE prs SET status='closed', last_error='closed: no diff against main (stale branch)' WHERE number = ?", (pr_number,)) return {"pr": pr_number, "skipped": True, "reason": "no_diff_closed"} diff --git a/lib/merge.py b/lib/merge.py index a84e109..c1f3ca1 100644 --- a/lib/merge.py +++ b/lib/merge.py @@ -1771,6 +1771,7 @@ async def _handle_permanent_conflicts(conn) -> int: except Exception: pass + await forgejo_api("PATCH", repo_path(f"pulls/{pr_number}"), {"state": "closed"}) conn.execute( "UPDATE prs SET status = 'closed', last_error = 'conflict_permanent: closed + filed in archive' WHERE number = ?", (pr_number,),