Problem statement
The GitLab Contributors view in a project I help maintaining has been "broken" for a while now. Seemingly GitLab is incapable of understanding that certain usernames and / or email addresses belong to the same user.
Currently our GitLab Contributors view shows the following:
Dev A <dev_a@company.com>
DevB <dev_b@company.com>
devb <dev_b@private.com>
Dev C <dev_c@company.com>
Dev D <dev_d@private.com>
Dev D <dev_d@company.com>
DevD <dev_d@company.com>
...
As you can see some persons are the same, though they are represented by different contributor entries. In this sheet such examples are:
- Dev B
- Dev D
Where Dev B has two usernames that are associated with different email addresses respectively and Dev D has both the same username associated with two addresses, as well as the same address associated with two different usernames.
Attempted solutions
An initial attempt to fix this was undertaken via the web UI provided by GitLab. At GitLab > User Settings > Emails emails can be associated with an account. For the profile of Dev D this is looking as follows:
dev_d@company.com (Verified) [Primary email][Commit email][Default notification email]
dev_d@education.com (Verified)
dev_d@private.com (Verified)
So far this shows, that both <dev_d@company.com> as well as <dev_d@private.com> are associated with the same account. This does not prove sufficient for GitLab to map these addresses to the same user in the Contributors view.
A second attempt was undertaken, by providing a .mailmap file with mappings of primary username / email address to secondary usernames / email addresses.
The current .mailmap file looks like this:
Dev A <dev_a@company.com>
Dev C <dev_c@company.com>
Dev B <dev_b@company.com> DevB <dev_b@company.com>
Dev B <dev_b@company.com> devb <dev_b@private.com>
Dev D <dev_d@company.com> Dev D <dev_d@private.com>
Dev D <dev_d@company.com> DevD <dev_d@company.com>
...
When git shortlog -se is called locally with this .mailmap at project root, then the result appears to be correct. Every user is mentioned only once (which they are not, when no .mailmap file exists), the correct primary emails are displayed and the commits are accumulated.
This is also commited, pushed and thus should be known to GitLab, however the mailmap file currently exists on a branch, rather than the master. This is not an obstacle though, because the Contributors view can be displayed for branches as well. The .mailmap file provided leaves the Contributors view absolutely and entirely unaffected. All aliases representing the same users are still unmerged and not associated with the user and each other respectively.
Meta
- Ancient GitLab thread referencing this, seems buried though: https://gitlab.com/gitlab-org/gitlab-foss/-/issues/183
- Another thread describing the problem: https://gitlab.com/gitlab-org/gitlab/-/issues/215325
- Related thread: https://gitlab.com/gitlab-org/gitlab/-/issues/15577
- Git documentation on author mapping: https://git-scm.com/docs/git-shortlog#_mapping_authors
- GitLab open issue on mailmap support: https://gitlab.com/gitlab-org/gitlab/-/issues/14909 (so presumably GitLab cannot handle
.mailmapas of yet?)