diff --git a/swh/storage/postgresql/converters.py b/swh/storage/postgresql/converters.py --- a/swh/storage/postgresql/converters.py +++ b/swh/storage/postgresql/converters.py @@ -74,6 +74,11 @@ """ if fullname is None: return None + + if name is None and email is None: + # The fullname hasn't been parsed, try that again + return Person.from_fullname(fullname) + return Person(fullname=fullname, name=name, email=email,) diff --git a/swh/storage/tests/storage_tests.py b/swh/storage/tests/storage_tests.py --- a/swh/storage/tests/storage_tests.py +++ b/swh/storage/tests/storage_tests.py @@ -1150,8 +1150,8 @@ revision, synthetic=False, metadata=None, - committer=attr.evolve(revision.committer, name=None, email=None), - author=attr.evolve(revision.author, name=None, email=None), + committer=Person.from_fullname(revision.committer.fullname), + author=Person.from_fullname(revision.author.fullname), type=RevisionType.GIT, ) for revision in revisions diff --git a/swh/storage/tests/test_postgresql_converters.py b/swh/storage/tests/test_postgresql_converters.py --- a/swh/storage/tests/test_postgresql_converters.py +++ b/swh/storage/tests/test_postgresql_converters.py @@ -177,10 +177,10 @@ def test_db_to_author(): # when - actual_author = converters.db_to_author(b"fullname", b"name", b"email") + actual_author = converters.db_to_author(b"name ", b"name", b"email") # then - assert actual_author == Person(fullname=b"fullname", name=b"name", email=b"email",) + assert actual_author == Person.from_fullname(b"name ") def test_db_to_author_none(): @@ -191,6 +191,11 @@ assert actual_author is None +def test_db_to_author_unparsed(): + author = converters.db_to_author(b"Fullname ", None, None) + assert author == Person.from_fullname(b"Fullname ") + + def test_db_to_revision(): # when actual_revision = converters.db_to_revision( @@ -207,10 +212,10 @@ "type": "git", "directory": b"dir-sha1", "message": b"commit message", - "author_fullname": b"auth-fullname", + "author_fullname": b"auth-name ", "author_name": b"auth-name", "author_email": b"auth-email", - "committer_fullname": b"comm-fullname", + "committer_fullname": b"comm-name ", "committer_name": b"comm-name", "committer_email": b"comm-email", "metadata": {}, @@ -225,11 +230,11 @@ assert actual_revision == Revision( id=b"revision-id", author=Person( - fullname=b"auth-fullname", name=b"auth-name", email=b"auth-email", + fullname=b"auth-name ", name=b"auth-name", email=b"auth-email", ), date=None, committer=Person( - fullname=b"comm-fullname", name=b"comm-name", email=b"comm-email", + fullname=b"comm-name ", name=b"comm-name", email=b"comm-email", ), committer_date=None, type=RevisionType.GIT, @@ -256,7 +261,7 @@ "name": b"release-name", "comment": b"release comment", "synthetic": True, - "author_fullname": b"auth-fullname", + "author_fullname": b"auth-name ", "author_name": b"auth-name", "author_email": b"auth-email", "raw_manifest": None, @@ -266,7 +271,7 @@ # then assert actual_release == Release( author=Person( - fullname=b"auth-fullname", name=b"auth-name", email=b"auth-email", + fullname=b"auth-name ", name=b"auth-name", email=b"auth-email", ), date=None, id=b"release-id",