Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(find-dependencies): http->https redirections weren't followed #431

Merged
merged 1 commit into from
Aug 21, 2023
Merged
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
23 changes: 17 additions & 6 deletions edx_repo_tools/find_dependencies/find_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def find_real_url(url: str) -> Optional[str]:
"""Find the eventual real url for a redirected url."""
while True:
try:
resp = requests.head(url, timeout=60)
resp = requests.head(url, timeout=60, allow_redirects=True)
except requests.RequestException as exc:
print(f"Couldn't fetch {url}: {exc}")
return None
Expand Down Expand Up @@ -303,13 +303,25 @@ def process_directory():
repo_urls.update(check_py_dependencies())
return repo_urls

FIRST_PARTY_ORGS = ["openedx"]

SECOND_PARTY_ORGS = [
"edx", "edx-unsupported", "edx-solutions",
"mitodl",
"overhangio",
"open-craft", "eduNEXT", "raccoongang",
]

def urls_in_orgs(urls, orgs):
"""
Find urls that are in any of the `orgs`.
"""
return sorted(
url for url in urls
if any(f"/{org}/" in url for org in orgs)
)


def main(dirs=None):
"""
Analyze the requirements in all of the directories mentioned on the command line.
Expand All @@ -331,11 +343,10 @@ def main(dirs=None):

write_list(WORK_DIR / "repo_urls.txt", sorted(repo_urls))

seconds = sorted(
url for url in repo_urls
if any(f"/{org}/" in url for org in SECOND_PARTY_ORGS)
)
write_list(WORK_DIR / "second_party_urls.txt", sorted(seconds))
firsts = urls_in_orgs(repo_urls, FIRST_PARTY_ORGS)
write_list(WORK_DIR / "first_party_urls.txt", firsts)
seconds = urls_in_orgs(repo_urls, SECOND_PARTY_ORGS)
write_list(WORK_DIR / "second_party_urls.txt", seconds)

print("== DONE ==============")
print("Second-party:")
Expand Down