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 @@ -18,7 +18,10 @@ class GitHubMapping(BaseExtrinsicMapping, JsonMapping): name = "github" - mapping = CROSSWALK_TABLE["GitHub"] + mapping = { + **CROSSWALK_TABLE["GitHub"], + "topics": SCHEMA.keywords, # TODO: submit this to the official crosswalk + } string_fields = [ "archive_url", "created_at", @@ -27,6 +30,7 @@ "full_name", "html_url", "issues_url", + "topics", ] @classmethod 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 @@ -38,9 +38,6 @@ def test_compute_metadata_github(): - """ - testing only computation of metadata with hard_mapping_npm - """ content = b""" { "id": 80521091, @@ -140,3 +137,20 @@ "schema:dateCreated": "2017-01-31T13:05:39Z", "schema:dateModified": "2022-06-22T08:02:20Z", } + + +def test_github_topics(): + content = b""" +{ + "topics": [ + "foo", + "bar" + ] +} + """ + result = MAPPINGS["GitHubMapping"]().translate(content) + assert set(result.pop("keywords", [])) == {"foo", "bar"}, result + assert result == { + "@context": CONTEXT, + "type": "forge:Repository", + }