From bc2211ac858a5ab5b773f20f1b19438679749257 Mon Sep 17 00:00:00 2001 From: fma-rc <188743521+fma-rc@users.noreply.github.com> Date: Thu, 15 Oct 2026 15:57:33 +0200 Subject: [PATCH] fix(tools): link overlapping pull requests without cross-referencing them --- tools/pr_overlap.py | 8 ++++++-- tools/tests/test_pr_overlap.py | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/pr_overlap.py b/tools/pr_overlap.py index b82912cd76..6a558f828d 100644 --- a/tools/pr_overlap.py +++ b/tools/pr_overlap.py @@ -188,6 +188,10 @@ def spans(conflicts, blob): for s, e in ranges) for path, ranges in sorted((conflicts or {}).items())) +def pull(blob, number): + return f'[PR {number}]({blob.split("/blob/", 1)[0].replace("https://github.com/", "https://www.github.com/", 1)}/pull/{number})' + + def report(rows, blob): if not rows: return "" @@ -204,7 +208,7 @@ def report(rows, blob): "|---|---|---|---|", ]) for number, found in sorted(confirmed.items()): - lines.append(f'| #{number} | {spans(found.get("conflicts"), blob)} | {cell(found.get("exports"))} | {cell(found["added"])} |') + lines.append(f'| {pull(blob, number)} | {spans(found.get("conflicts"), blob)} | {cell(found.get("exports"))} | {cell(found["added"])} |') if uncompared: if confirmed: lines.append("") @@ -216,7 +220,7 @@ def report(rows, blob): "|---|---|", ]) for number, files in sorted(uncompared.items()): - lines.append(f"| #{number} | {cell(files)} |") + lines.append(f"| {pull(blob, number)} | {cell(files)} |") return "\n".join(lines) + "\n" diff --git a/tools/tests/test_pr_overlap.py b/tools/tests/test_pr_overlap.py index e76ab38727..dad871a5e2 100644 --- a/tools/tests/test_pr_overlap.py +++ b/tools/tests/test_pr_overlap.py @@ -1,5 +1,6 @@ import json import os +import re import shutil import subprocess import sys @@ -216,6 +217,14 @@ class ConflictTests(unittest.TestCase): self.assertIn("`shared.cpp`", report) self.assertTrue(report.startswith(pr_overlap.MARKER)) + def test_report_links_pull_requests_without_cross_references(self): + rows = {2: {"added": set(), "conflicts": {"other.cpp": [(1, 1)]}}, + 3: {"added": set(), "uncompared": {"shared.cpp"}}} + report = pr_overlap.report(rows, "https://github.com/owner/project/blob/base") + self.assertIsNone(re.search(r"#\d|https://github\.com/owner/project/(pull|issues)/", report)) + self.assertIn("[PR 2](https://www.github.com/owner/project/pull/2)", report) + self.assertIn("[PR 3](https://www.github.com/owner/project/pull/3)", report) + class UnicodePathTests(unittest.TestCase): def test_scans_and_reports_conflicts_with_git_path_quoting_enabled(self):