Skip to content

Commit 9bb3fc7

Browse files
authored
[Patch] bypass repository metrics when not hosted on GitHub (#300)
* [Patch] bypass repository metrics when not hosted on GitHub * Update src/pyosmeta/github_api.py
1 parent 2dc79e4 commit 9bb3fc7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/pyosmeta/github_api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ def _get_metrics_graphql(
326326
data = response.json()
327327
repo_data = data["data"]["repository"]
328328

329+
if not repo_data:
330+
logger.warning(
331+
f"Repository metrics not able to be retrieved (it may not be on GitHub?): {repo_info['owner']}/{repo_info['repo_name']}."
332+
)
333+
return None
334+
329335
return {
330336
"name": repo_data["name"],
331337
"description": repo_data["description"],
@@ -381,7 +387,8 @@ def get_repo_meta(
381387
If the repository is not found or access is forbidden, it returns None.
382388
"""
383389
metrics = self._get_metrics_graphql(repo_info)
384-
metrics["contrib_count"] = self._get_contrib_count_rest(repo_info)
390+
if metrics is not None:
391+
metrics["contrib_count"] = self._get_contrib_count_rest(repo_info)
385392

386393
return metrics
387394

0 commit comments

Comments
 (0)