-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Is your feature request related to a problem? Please describe.
Follow ip to #1175
GitProxy used to assume that git clients are configured such that the user.name config is set to the GitHub username and would use that to render liks to the GitHub user profile. However, this is not a correct assumption as the user.name is usually set to a human readable name (see: https://docs.github.com/en/get-started/git-basics/setting-your-username-in-git#setting-your-git-username-for-every-repository-on-your-computer).
#1175 seeks to remove the estimated profile links, ot replace them with email links, as the email should always be set on a commit (meaning it will be present even for a bare git server). However, if we can identify a supported git SCM provider the users details should be resolved to profile url and link rendered to it.
Describe the solution you'd like
GitProxy should:
- Be able to render links to user profiles (in push detail views and user profiles) for multiple platforms (at least GitHub and GitLab)
- Be able to resolve users to user profile links rather than guessing at them, either:
- via API calls
- via its own user database
Describe alternatives you've considered
Looking around, its not easy to get the GitHub id from the email address - at best you can search against the single, optional public/primary email address with the API. E.g. This works: https://api.github.com/search/users?q=solankiarpit1997@gmail.com but this doesn't https://api.github.com/search/users?q=kristopher.west@natwest.com
This lib offers an alternative based on searching for commits with the email address: https://github.com/sindresorhus/github-username
I've not tried it, but it might provide a solution
For Gitlab there is a user API for lookup, but it will require an API access token to return results:
https://docs.gitlab.com/api/users/#as-a-regular-user
The final alternative is to support multiple fields for user names at SCM providers and to use those to resolve emails to usernames/profile links. However, we only currently require commiters (those pushing the changes) to have accounts in GitProxy and the permission to push, so we can expect some (otherwise legal) authors to not resolve by this method.