RepoSense icon indicating copy to clipboard operation
RepoSense copied to clipboard

Option to merge/map git-users

Open christophhalbi opened this issue 2 years ago • 3 comments

What feature(s) would you like to see in RepoSense?

It would be quite useful to merge/map git-users of same origin to one user.

Is the feature request related to a problem?

Problem: the "same" (git-)user commits into the repo with different usernames like

Simon tester (tester)
simon (tester)

If possible, describe the solution

You could bring in an option to merge/map git usernames into one user.

christophhalbi avatar Jun 15 '22 07:06 christophhalbi

@christophhalbi Indeed, authors using different git usernames is a problem. The current remedy is to specify those different git usernames in the Author's Git Author Name of the author-config.csv https://reposense.org/ug/configFiles.html#author-config-csv after which RepoSense will consider all of them as one author and merge their activities together. Is that along the lines of what you had in mind?

damithc avatar Jun 15 '22 08:06 damithc

@damithc Thx! That looks great, I'll have a look.

christophhalbi avatar Jun 15 '22 08:06 christophhalbi

I will be looking into this.

lawwm avatar Sep 26 '22 15:09 lawwm

I've tried looking into the issue, but I'm not exactly sure what the problem is. It is possible that I missed out on something.

When I specify multiple Author's Git Author Name in the author-config.csv, it manages to merge them together into one author, so that method already works.

Is the issue then merging users when author-config.csv is not specified? In that case, GitShortlog.getAuthors(config) will be called instead, which means that git host id and display name will be the same.

lawwm avatar Oct 09 '22 14:10 lawwm

Is the issue then merging users when author-config.csv is not specified?

@lawwm Yes, the proposed feature is an alternative (or can be complementary) to the current way of specifying multiple author names.

damithc avatar Oct 09 '22 14:10 damithc

GitShortlog.getAuthors(config) is used to get author names, which runs git log --pretty=short | git shortlog --summary to get git usernames. An email flag --email can be added to git shortlog to include git email.

Maybe different usernames can be mapped to the same email? However, I'm not sure if it would be a useful feature?

lawwm avatar Oct 26 '22 16:10 lawwm

Currently, git has a nifty feature called mailmap. By specifying a .mailmap file in the top level of the repository, it allows a user to map author/commiter names and/or e-mail addresses.

After some investigation, it seems this feature already innately works, and no modification of RepoSense backend is required. It also seems to have priority over any mappings done by author-config.csv. I think that we can add some documentation about the option to use git's mailmap feature and close this issue.

Before

2 seperate authors, "Marcus" and "Marcus Tang" image

After adding .mailmap file

.mailmap mapping "Marcus" to "Marcus Tang":

Marcus Tang <[email protected]> Marcus <[email protected]>

image

MarcusTXK avatar Feb 12 '23 03:02 MarcusTXK

Thanks for the investigation. That's really interesting. Maybe under this section of the UG https://reposense.org/ug/customizingReports.html#get-target-repos-to-provide-more-info

chan-j-d avatar Feb 12 '23 08:02 chan-j-d