Skip to content

Commit 8b04788

Browse files
committed
github api: detect archived repos and set developmentstatus accordingly (to unsupported or abandoned)
1 parent 2ce5898 commit 8b04788

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

codemeta/parsers/gitapi.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
AttribDict,
1111
SDO,
1212
CODEMETA,
13+
REPOSTATUS,
1314
license_to_spdx,
1415
parse_human_name,
1516
generate_uri,
17+
delete_repostatus,
1618
)
1719

1820
GITAPI_REPO_BLACKLIST = [
@@ -192,6 +194,17 @@ def _parse_github(
192194
if response.get("has_issues", False) and response.get("html_url"):
193195
g.add((res, CODEMETA.issueTracker, Literal(response["html_url"] + "/issues")))
194196

197+
if response.get("archived", False):
198+
reponame = response.get("full_name") #namespace/repo
199+
releases_api_url = f"https://api.github.com/repos/{reponame}/releases"
200+
releases = rate_limit_get(releases_api_url, "github")
201+
if (res, CODEMETA.developmentStatus, REPOSTATUS.active) in g or (res, CODEMETA.developmentStatus, REPOSTATUS.inactive) or len(releases) > 0:
202+
delete_repostatus(g,res)
203+
g.add((res,CODEMETA.developmentStatus, REPOSTATUS.unsupported))
204+
else:
205+
delete_repostatus(g,res)
206+
g.add((res,CODEMETA.developmentStatus, REPOSTATUS.abandoned))
207+
195208
if "owner" in response:
196209
owner = response["owner"]["login"]
197210
owner_api_url = f"{users_api_url}{owner}"
@@ -229,6 +242,8 @@ def _parse_github(
229242
g.add((owner_res, SDO.url, Literal(response.get("blog"))))
230243

231244

245+
246+
232247
gitlab_crosswalk_table = {
233248
SDO.codeRepository: "web_url",
234249
SDO.dateCreated: "created_at",

0 commit comments

Comments
 (0)