From e918cca2c985e71fae893ecddc2f6bb0f37554b4 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 28 Mar 2026 22:15:12 +0000 Subject: [PATCH] test(repo): generalize docs drift guard --- scripts/tests/test_repo_docs_link_drift.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/tests/test_repo_docs_link_drift.py b/scripts/tests/test_repo_docs_link_drift.py index 76c60d603..1f9072340 100644 --- a/scripts/tests/test_repo_docs_link_drift.py +++ b/scripts/tests/test_repo_docs_link_drift.py @@ -3,19 +3,17 @@ from __future__ import annotations +import re import unittest from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[2] -FORBIDDEN_SNIPPETS = ( - "https://github.com/rcourtman/Pulse/blob/main/", - "https://github.com/rcourtman/Pulse/blob/master/", - "https://github.com/rcourtman/Pulse/tree/main/docs/", - "https://github.com/rcourtman/Pulse/tree/master/docs/", - "https://raw.githubusercontent.com/rcourtman/Pulse/main/docs/", - "https://raw.githubusercontent.com/rcourtman/Pulse/master/docs/", +FORBIDDEN_PATTERNS = ( + re.compile(r"https://github\.com/[^/\s\"')]+/[^/\s\"')]+/blob/(?:main|master)/"), + re.compile(r"https://github\.com/[^/\s\"')]+/[^/\s\"')]+/tree/(?:main|master)/docs/"), + re.compile(r"https://raw\.githubusercontent\.com/[^/\s\"')]+/[^/\s\"')]+/(?:main|master)/docs/"), ) SKIP_DIR_NAMES = { @@ -81,9 +79,10 @@ class RepoDocsLinkDriftTest(unittest.TestCase): except UnicodeDecodeError: continue - for snippet in FORBIDDEN_SNIPPETS: - if snippet in content: - offenders.append(f"{rel_path}: {snippet}") + for pattern in FORBIDDEN_PATTERNS: + match = pattern.search(content) + if match: + offenders.append(f"{rel_path}: {match.group(0)}") self.assertEqual( offenders,