fix(tools): link overlapping pull requests without cross-referencing them

This commit is contained in:
fma-rc committed 2026-10-15 16:00:40 +02:00
1 parent 0dab493f5b
commit bc2211ac85
2 files changed
+15 -2

No files matched your search

+6 -2
View File
@@ -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"
+9
View File
@@ -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):