gitsnitch
is a simple tool that finds and prints a GitHub user's email
addresses.
Give gitsnitch
a GitHub username or profile URL, like gruns
or
https://github.com/gruns, and it finds and prints that user's email
addresses by examining commits across their GitHub repos.
To use, provide gitsnitch
with a GitHub username or profile URL and
let it go to work. gitsnitch
will, in turn:
- Get a list of that user's repos via the GitHub API.
- Iterate through each of those repos, prioritizing non-forked repos are forked repos.
- For each repo, iterate through that repo's commits via the GitHub API and examine the committers' email addresses.
- Collate a list of each repo's committers and, notably, their email addresses.
- Output a nicely formatted summary of committers and their email addresses, sorted by number of commits.
Example:
$ gitsnitch https://github.com/gruns
https://github.com/gruns/autokey-to-espanso
Ansgar Grunseid grunseid@gmail.com 2 commits, latest on Jan 07, 2023
https://github.com/gruns/furl
Ansgar Grunseid grunseid@gmail.com 23 commits, latest on Jun 28, 2022
Ben Greiner code@bnavigator.de 3 commits, latest on Mar 29, 2021
Tim Gates tim.gates@iress.com 1 commits, latest on Jul 30, 2022
https://github.com/gruns/fallout-sonora-translation
Ansgar Grunseid grunseid@gmail.com 7 commits, latest on Sep 22, 2023
...
That's it. Simple.
By default, this script does not need a GitHub API token because GitHub API endpoints, like https://api.github.com/users/gruns/repos, can be accessed without an API token at a low rate limit. However, if you encounter API rate limits, like
Exception: Error fetching repositories: {"message":"API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)", "documentation_url": "https://docs.github.com/rest/..."}
you'll need to create an API token and add it your environment. To
create an API token for gitsnitch
:
- Head to https://github.com/ and log in to your account.
- Open your profile picture in the top-right corner and click
Settings
. - Click
Developer settings
in the left-hand sidebar. - Under
Developer settings
, clickPersonal access tokens
->Tokens (classic)
. - Click
Generate new token
. Then select at leastread:user
anduser:email
underuser
. - Click
Generate token
. - Copy the generated token. Be sure to save it; you won't be able to view it again.
Then add this token to your environment with
export GITHUB_TOKEN=<your_api_token>
Finally, re-run gitsnitch
as normal. Boom.
Installing GitSnitch with pip is easy.
$ pip3 install gitsnitch