Skip to content

Commit

Permalink
Filter out known false positive GitHub fragments that we can't check.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira Emma Hopwood <[email protected]>
  • Loading branch information
daira committed Oct 28, 2023
1 parent 85f5193 commit dbd852a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions links_and_dests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import ssl
from io import BytesIO, StringIO
import json
import re

try:
from bs4 import BeautifulSoup
Expand All @@ -23,6 +24,9 @@
print("Please upgrade certifi using `pip install --upgrade certifi`.\n")
sys.exit(1)

GITHUB_LINE_FRAGMENT = re.compile('L[0-9]+')


def get_links_and_destinations_from_pdf(f):
try:
from PyPDF2 import PdfFileReader
Expand Down Expand Up @@ -204,8 +208,13 @@ def main(args):
print("(link target not checked)", end=" ")
status = "✓"
elif fragment not in dests:
errors.append("Missing link target: " + what)
status = "❌"
# Filter out known false positive GitHub fragments that we can't check.
if last_url.startswith("https://github.com/") and (fragment.startswith('diff-') or GITHUB_LINE_FRAGMENT.match(fragment) is not None):
print("(link target not checked)", end=" ")
status = "✓"
else:
errors.append("Missing link target: " + what)
status = "❌"
else:
status = "✓"
else:
Expand Down

0 comments on commit dbd852a

Please sign in to comment.