Page MenuHomeSoftware Heritage

D8416.id30383.diff
No OneTemporary

D8416.id30383.diff

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",
+ }

File Metadata

Mime Type
text/plain
Expires
Dec 19 2024, 7:53 PM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3227967

Event Timeline