diff --git a/swh/indexer/metadata_dictionary/github.py b/swh/indexer/metadata_dictionary/github.py --- a/swh/indexer/metadata_dictionary/github.py +++ b/swh/indexer/metadata_dictionary/github.py @@ -8,7 +8,7 @@ from rdflib import RDF, BNode, Graph, Literal, URIRef from swh.indexer.codemeta import CROSSWALK_TABLE -from swh.indexer.namespaces import ACTIVITYSTREAMS, FORGEFED, SCHEMA +from swh.indexer.namespaces import ACTIVITYSTREAMS, CODEMETA, FORGEFED, SCHEMA from .base import BaseExtrinsicMapping, JsonMapping, produce_terms from .utils import prettyprint_graph # noqa @@ -24,9 +24,7 @@ "clone_url": SCHEMA.codeRepository, } uri_fields = [ - "archive_url", "clone_url", - "issues_url", ] date_fields = [ "created_at", @@ -46,6 +44,15 @@ graph.remove((root, RDF.type, SCHEMA.SoftwareSourceCode)) graph.add((root, RDF.type, FORGEFED.Repository)) + if content_dict.get("has_issues"): + graph.add( + ( + root, + CODEMETA.issueTracker, + URIRef(content_dict["html_url"] + "/issues"), + ) + ) + def get_root_uri(self, content_dict: dict) -> URIRef: if isinstance(content_dict.get("html_url"), str): return URIRef(content_dict["html_url"]) diff --git a/swh/indexer/tests/metadata_dictionary/test_github.py b/swh/indexer/tests/metadata_dictionary/test_github.py --- a/swh/indexer/tests/metadata_dictionary/test_github.py +++ b/swh/indexer/tests/metadata_dictionary/test_github.py @@ -63,6 +63,8 @@ "created_at": "2017-01-31T13:05:39Z", "updated_at": "2022-06-22T08:02:20Z", "pushed_at": "2022-06-29T09:01:08Z", + "archive_url": "https://api.github.com/repos/SoftwareHeritage/swh-indexer/{archive_format}{/ref}", + "issues_url": "https://api.github.com/repos/SoftwareHeritage/swh-indexer/issues{/number}", "git_url": "git://github.com/SoftwareHeritage/swh-indexer.git", "ssh_url": "git@github.com:SoftwareHeritage/swh-indexer.git", "clone_url": "https://github.com/SoftwareHeritage/swh-indexer.git", @@ -114,7 +116,7 @@ "subscribers_count": 6 } - """ + """ # noqa result = MAPPINGS["GitHubMapping"]().translate(content) assert result == { "@context": CONTEXT, @@ -158,3 +160,19 @@ "type": "forge:Repository", "id": "https://github.com/SoftwareHeritage/swh-indexer", } + + +def test_github_issues(): + content = b""" +{ + "html_url": "https://github.com/SoftwareHeritage/swh-indexer", + "has_issues": true +} + """ + result = MAPPINGS["GitHubMapping"]().translate(content) + assert result == { + "@context": CONTEXT, + "type": "forge:Repository", + "id": "https://github.com/SoftwareHeritage/swh-indexer", + "issueTracker": "https://github.com/SoftwareHeritage/swh-indexer/issues", + }