Add author_name and author_email to RepositoryFile#1314
Conversation
There was a problem hiding this comment.
Are you sure the gitlab sends those attributes?
Doc: https://docs.gitlab.com/api/repository_files/#retrieve-a-file-from-a-repository
GET https://<server>/api/v4/projects/<id>/repository/files/<path>?ref=main
Is sending back:
{
"file_name": "file.txt",
"file_path": "file.txt",
"size": 560,
"encoding": "base64",
"content_sha256": "1dd2cbbc6db2d37daa8397ef186cabcd365d366358c5130d3e321c62868a49af",
"ref": "main",
"blob_id": "e2a869f70d890f99ed3e86f069da49dabdac8a78",
"commit_id": "5dd394122833ccade0474991125f73cd2514f52c",
"last_commit_id": "af6990f7c535fd200bb9ec44acd1b99e79ee4746",
"execute_filemode": false,
"content": "..."
}There was a problem hiding this comment.
Now I've noticed a difference. The same class RepositoryFile is used to create and get a file.
When creating the file, the author_name and author_email attributes exist, but not when retrieving it.
Do you have any suggestions?
There was a problem hiding this comment.
Good point!
I would love to have objects really corresponding to the exact JSON exchanged (request/response)… Otherwise people to a read request and complains that some values are null and are not expecting it.
If the gitlab4j client is sharing classes as you noticed this is impossible to implement… Probably we could sub-class the object used in the creation request. This would be an acceptable non-breaking change for now.
According to the GitLab documentation https://docs.gitlab.com/api/repository_files/#create-a-file-in-a-repository
It's possible to define the author's email address and commit author's name.
I added these parameters to the RepositoryFile and have already successfully performed local tests.