Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions format_checker/pr_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
)


# URL pattern used in Notes validation
url_pattern = r"https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}"

# Contains information and regexes unique to pr-data.csv and gr-data.csv files
data = {
"columns": [
Expand Down Expand Up @@ -65,9 +68,9 @@
"PR Link": re.compile(
r"((https:\/\/github.com\/((\w|\.|-)+\/)+)(pull\/\d+))"
),
"Notes": re.compile(
r"(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})"
),
"URL Base": re.compile(url_pattern),
"Notes": re.compile(rf"({url_pattern})(;.*)?"),
"Notes URL with Text": re.compile(rf"({url_pattern})\s+.+"),
}


Expand Down Expand Up @@ -152,7 +155,11 @@ def check_notes(filename, row, i, log):
"""Checks validity of Notes."""

if not data["Notes"].fullmatch(row["Notes"]):
log_std_error(filename, log, i, row, "Notes")
# Check if it's a URL followed by text without semicolon
if data["Notes URL with Text"].fullmatch(row["Notes"]):
log_std_error(filename, log, i, row, "Notes", "URL and additional text must be separated by semicolon (ex: 'URL; description')")
else:
log_std_error(filename, log, i, row, "Notes")


def check_forked_project(filename, row, i, log):
Expand Down