Include a list of contributors to RL
Closed this issue ยท 3 comments
As spoken with @jgvictores, we'd like to add a section that lists all people who contributed to the software at roboticslab-uc3m. It would render pretty much like the MediaWiki credits, but preferably including the GitHub nickname (if available) along with the proper name.
Compare with robotology/gazebo-yarp-plugins:
The updateAuthors.sh script invokes a Git command that uses the mappings defined in .mailmap to correctly map commiter names and commit emails to proper names/emails:
git log --format='%aN <%aE>' | sort -f | uniq >> AUTHORS
The good thing is that this command can be invoked on a custom working directory using a custom mailmap file (through mailmap.file
) located anywhere. For instance, if we have a root git/ directory (which is our current working directory), the mailmap file is placed within git/tools/mymailmap.txt, and we want to extract contributors for git/myfancyrepo/:
git -C myfancyrepo -c mailmap.file=/path/to/git/tools/mymailmap.txt log --format='%aN <%aE>'
Note that mailmap.file
requires an absolute path.
See also:
To list all source (i.e. no forks) repos in roboticslab-uc3m using the GitHub CLI app (need to do gh auth login
first):
gh repo list roboticslab-uc3m --source --json name --limit 500
Sample JSON output:
[
{
"name": "teo-configuration-files"
},
{
"name": "teo-openrave-models"
}
]
To avoid cloning 161 repositories, it is possible to extract the list of contributors through the GH API:
gh api --header "Accept: application/vnd.github+json" --method GET /repos/roboticslab-uc3m/yarp-devices/contributors -F anon=true -F per_page=100
(anon=true
accounts for authors that did not link their email to a GH account)
Docs:
- https://docs.github.com/en/rest/repos/repos#list-organization-repositories
- https://docs.github.com/en/rest/repos/repos#list-repository-contributors
- https://docs.github.com/en/rest/commits/commits#list-commits
- https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api#using-query-parameters
Done at 0d1046e. This list doesn't cover contributors who didn't upload their code to our org (forks are not included), nor SVN-era authors.
I finally decided to fetch data through the GH API to avoid cloning 161 repos. The tool of choice was PyGithub and the code was placed in scripts/update_contributors.py.
Note GitHub credentials are required with the correct permissions set in order to be able to retrieve information about private repositories. I am using the new fine-grained tokens (docs):
- check the 'All repositories' checkbox
- enable repository permissions: metadata (read-only)
- enable organization permissions: members (read-only)
The script uses dev-aliases.yaml as a mapping of committer aliases in case anonymous contributors (i.e. authors of commits in which the specified email couldn't be linked to an existing GitHub account) appear several times on the list, or their actual GH account is listed under a different name.
See contributors.md (GitBook). For registered GH users, their real name is displayed first if provided, and the GH username in parentheses, or only the latter otherwise. For anonymous users, if there was no mapping found, the commit author is displayed as-is.
See also https://pygithub.readthedocs.io/en/latest/apis.html (/orgs/{org}/repos
+ /repos/{owner}/{repo}/contributors
).
As spoken with @jgvictores again and in order to accomodate more scenarios, the script now ignores 3rd-party repositories such as jr3pci-linux, which have been mirrored in our org, but were mostly contributed to by non-RL devs: 89b6afc. In order to mark a repo as such, use topics (org config): in this case, add the 3rd-party
topic.