Problem/Motivation
"versioncontrol_gitlab_key" is usually the key for the admin user to communicate with the Gitlab api. If you create projects, issues or comments using the gitlab client, all these will be authored by the admin user.
In a situation where we are migrating issues or comments, we want to keep the author of those, specially if the user is already in gitlab. Gitlab offers the "impersonation_tokens" (https://docs.gitlab.com/ee/api/users.html#get-an-impersonation-token-of-...) to achieve this.
Currently, "versioncontrol_gitlab_get_client" method will login with the admin key and there is no possibility of impersonating a user.
Steps to reproduce
Get a client via "versioncontrol_gitlab_get_client()" and create an issue or a note. It will be assigned to the admin user and you have no way of assigning it to somebody else.
Proposed resolution
Give a second optional parameter to "versioncontrol_gitlab_get_client" to allow for a different key or provide a new method for it.
Remaining tasks
Provide patch or MR.
User interface changes
None.
API changes
New method available.
Data model changes
None.
Issue fork versioncontrol_gitlab-3296136
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
fjgarlin commentedChecking the documentation, the "sudo" option might be used for that. It's not very clear based on the code and the comments within it, but the web documentation here https://docs.gitlab.com/ee/api/#sudo seems to indicate that.
I will test this and either work on the issue or close it based on the result.
Comment #4
fjgarlin commentedComment #5
drummWe have impersonation built in, call
versioncontrol_gitlab_get_client()with a Git username argument. For example, https://git.drupalcode.org/project/drupalorg/-/blob/1eb88c35a88f62b25099...Comment #6
fjgarlin commentedGreat! I saw that shortly after I filed the issue. Thanks for the link and the code sample.