From 1e01841072badcde54e9a61ca476f27279bade90 Mon Sep 17 00:00:00 2001 From: emirplus Date: Mon, 19 Oct 2026 21:04:11 +0300 Subject: [PATCH 1/2] fix(tools): recognize markdown links and pull request URLs in pr_overlap dependencies --- tools/pr_overlap.py | 3 +++ tools/tests/test_pr_overlap_dependencies.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/pr_overlap.py b/tools/pr_overlap.py index ca1bc134e5..923b1bcb54 100644 --- a/tools/pr_overlap.py +++ b/tools/pr_overlap.py @@ -41,6 +41,9 @@ def upstream(): def depends_on(body): body = re.sub(r"", "", body or "", flags=re.S) + body = re.sub(r"\[([^\]]*)\]\(https?://github\.com/[^/\s]+/[^/\s]+/pull/(\d+)\)", r"#\2", body) + body = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", body) + body = re.sub(r"https?://github\.com/[^/\s]+/[^/\s]+/pull/(\d+)\b", r"#\1", body) match = next((match for match in DEPENDS.finditer(body) if match.group(1).strip()), None) or PLAIN_DEPENDS.search(body) return {int(n) for n in re.findall(r"#(\d+)", match.group(1))} if match else set() diff --git a/tools/tests/test_pr_overlap_dependencies.py b/tools/tests/test_pr_overlap_dependencies.py index 11754c81b7..f66a443af5 100644 --- a/tools/tests/test_pr_overlap_dependencies.py +++ b/tools/tests/test_pr_overlap_dependencies.py @@ -47,6 +47,19 @@ class DependencyTests(unittest.TestCase): with self.subTest(body=body): self.assertEqual(pull_requests(body)[1]["depends"], {2, 3}) + def test_markdown_links_and_full_urls(self): + for body in ( + "- [x] Depends on: [#2](https://github.com/owner/repo/pull/2)", + "- [x] Depends on: https://github.com/owner/repo/pull/2", + "- [x] Depends on: [PR #2](https://github.com/owner/repo/pull/2)", + "Depends on: [#2](https://github.com/owner/repo/pull/2), [#3](https://github.com/owner/repo/pull/3)", + "Depends on:\n- [#2](https://github.com/owner/repo/pull/2)\n- [#3](https://github.com/owner/repo/pull/3)", + "- [x] Depends on: [none](https://example.com)", + ): + with self.subTest(body=body): + expected = set() if "none" in body else ({2, 3} if "3" in body else {2}) + self.assertEqual(pull_requests(body)[1]["depends"], expected) + def test_later_references_are_not_dependencies(self): for newline in ("\n", "\r\n"): for declaration in ("Depends on #2.", "Depends on: #2"): From 486eb18dc115a7bf3b64fc0937963de34a5a1b36 Mon Sep 17 00:00:00 2001 From: emirplus Date: Wed, 21 Oct 2026 19:36:15 +0300 Subject: [PATCH 2/2] fix(tools): restrict pull request URL matching to current repository in pr_overlap --- tools/pr_overlap.py | 8 +++++--- tools/tests/test_pr_overlap_dependencies.py | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/pr_overlap.py b/tools/pr_overlap.py index 923b1bcb54..6699df9ebf 100644 --- a/tools/pr_overlap.py +++ b/tools/pr_overlap.py @@ -41,13 +41,15 @@ def upstream(): def depends_on(body): body = re.sub(r"", "", body or "", flags=re.S) - body = re.sub(r"\[([^\]]*)\]\(https?://github\.com/[^/\s]+/[^/\s]+/pull/(\d+)\)", r"#\2", body) + repo = re.escape(globals().get("REPO", "boykopovar/AnyPS5")) + repo_pattern = rf"(?:{repo}|boykopovar/AnyPS5)" + body = re.sub(rf"\[([^\]]*)\]\(https?://github\.com/{repo_pattern}/pull/(\d+)(?:[#/?][^)\s]*)?\)", r"#\2", body, flags=re.IGNORECASE) + body = re.sub(rf"\[([^\]]*)\]\(https?://github\.com/(?!{repo_pattern}/)[^/\s]+/[^/\s]+/pull/\d+[^)\s]*\)", "", body, flags=re.IGNORECASE) body = re.sub(r"\[([^\]]+)\]\([^)]+\)", r"\1", body) - body = re.sub(r"https?://github\.com/[^/\s]+/[^/\s]+/pull/(\d+)\b", r"#\1", body) + body = re.sub(rf"https?://github\.com/{repo_pattern}/pull/(\d+)\b(?:/[^\s]*)?", r"#\1", body, flags=re.IGNORECASE) match = next((match for match in DEPENDS.finditer(body) if match.group(1).strip()), None) or PLAIN_DEPENDS.search(body) return {int(n) for n in re.findall(r"#(\d+)", match.group(1))} if match else set() - def open_prs(base): query = urlencode({"state": "open", "base": base, "per_page": 100}) out = gh("api", "--paginate", f"repos/{REPO}/pulls?{query}") diff --git a/tools/tests/test_pr_overlap_dependencies.py b/tools/tests/test_pr_overlap_dependencies.py index f66a443af5..9af379f868 100644 --- a/tools/tests/test_pr_overlap_dependencies.py +++ b/tools/tests/test_pr_overlap_dependencies.py @@ -52,12 +52,17 @@ class DependencyTests(unittest.TestCase): "- [x] Depends on: [#2](https://github.com/owner/repo/pull/2)", "- [x] Depends on: https://github.com/owner/repo/pull/2", "- [x] Depends on: [PR #2](https://github.com/owner/repo/pull/2)", + "- [x] Depends on: https://github.com/owner/repo/pull/2/files", + "- [x] Depends on: https://github.com/owner/repo/pull/2#issuecomment-1", + "- [x] Depends on: https://github.com/BOYKOPOVAR/AnyPS5/pull/2", "Depends on: [#2](https://github.com/owner/repo/pull/2), [#3](https://github.com/owner/repo/pull/3)", "Depends on:\n- [#2](https://github.com/owner/repo/pull/2)\n- [#3](https://github.com/owner/repo/pull/3)", "- [x] Depends on: [none](https://example.com)", + "- [x] Depends on: https://github.com/shadps4-emu/shadPS4/pull/1234", + "- [x] Depends on: [#1234](https://github.com/shadps4-emu/shadPS4/pull/1234)", ): with self.subTest(body=body): - expected = set() if "none" in body else ({2, 3} if "3" in body else {2}) + expected = set() if "none" in body or "shadps4" in body else ({2, 3} if "3" in body else {2}) self.assertEqual(pull_requests(body)[1]["depends"], expected) def test_later_references_are_not_dependencies(self):