From eb125bb15ce52ce1365eeb7514646286996004b7 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 22 Aug 2023 13:06:41 -0400 Subject: [PATCH] fix(find_dependencies): use any github repo project-url if need be When looking for the GitHub home of a PyPI package, if nothing is explicitly marked as Source or Home, use any Project-URL that is a GitHub repo. --- edx_repo_tools/find_dependencies/find_dependencies.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/edx_repo_tools/find_dependencies/find_dependencies.py b/edx_repo_tools/find_dependencies/find_dependencies.py index 05f91342..04dd64f2 100644 --- a/edx_repo_tools/find_dependencies/find_dependencies.py +++ b/edx_repo_tools/find_dependencies/find_dependencies.py @@ -241,9 +241,12 @@ def repo_url_from_tgz(tgz_path: str) -> Optional[str]: SOURCE_URL_REGEXES = [ + # These regexes are tried in order. The first group is the extracted URL. r"(?i)^Project-URL: Source.*,\s*(.*)$", r"(?i)^Home-page: (.*)$", r"(?i)^Project-URL: Home.*,\s*(.*)$", + # If we can't find a URL marked as home, then use any GitHub repo URL. + r"(?i)^Project-URL: [^,]+,\s*(https?://github.com/[^/]+/[^/]+)$", ] def repo_url_from_metadata(filename, metadata):