mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
fix(tools): link overlapping pull requests without cross-referencing them
This commit is contained in:
2 files changed
+15
-2
No files matched your search
+6
-2
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user