From b979b46c98becb0897a8aa3e4585175878b28267 Mon Sep 17 00:00:00 2001 From: Honza Javorek Date: Thu, 16 May 2024 10:38:06 +0200 Subject: [PATCH] fix https://github.com/juniorguru/hen/issues/11 --- jg/hen/core.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/jg/hen/core.py b/jg/hen/core.py index 346c607..3ad17ff 100644 --- a/jg/hen/core.py +++ b/jg/hen/core.py @@ -98,9 +98,8 @@ async def check_profile_url( raise_on_error: bool = False, ) -> Summary: results = [] + username = parse_username(profile_url) try: - username = parse_username(profile_url) - import jg.hen.rules # noqa import jg.hen.insights # noqa @@ -125,21 +124,25 @@ async def check_profile_url( response = await github.rest.repos.async_get(username, minimal_repo.name) repo = response.parsed_data readme = None - try: - response = await github.rest.repos.async_get_readme( - username, - repo.name, - headers={"Accept": "application/vnd.github.html+json"}, - ) - readme = response.text - except RequestFailed as error: - if error.response.status_code != 404: - raise + pin = get_pin(pinned_urls, repo.html_url) + # For efficiency, ignore downloading README for archived repos + # which are not pinned + if pin is not None or not repo.archived: + try: + response = await github.rest.repos.async_get_readme( + username, + repo.name, + headers={"Accept": "application/vnd.github.html+json"}, + ) + readme = response.text + except RequestFailed as error: + if error.response.status_code != 404: + raise context = RepositoryContext( repo=repo, readme=readme, is_profile=repo.name == username, - pin=get_pin(pinned_urls, repo.html_url), + pin=pin, ) results.extend(await send(on_repo, context=context)) contexts.append(context)