2020 is almost over. (INSERT JOKE ABOUT HOW CRAPPY 2020 WAS FOR MOST PEOPLE HERE). Regardless of the year, I like to give myself an "annual review" every year. Part of that review is to see how much I coded in the past year. Not only is this just fun, but it could also give you some weight in your argument for a promotion or pay raise at your next review. 🤑
If you've used GitHub, you've probably seen their contribution calendar that looks something like this.
That's fine and dandy, but what if you aren't using GitHub? What if you want more info that could compare your performance to a team? All that and more will be discussed right after this quick commercial break!
Alright, let's get to business. This walk-through will work for ANY codebase that uses git for version control. My company uses Azure, so I don't get the nifty contribution calendar by default.
We will be using an npm package called "git-stats".
First, open up your terminal and install git-stats globally using:
npm i -g git-stats
Git stats will now keep track of your commits for future reference, but there's currently no data for it to work with. We need to install another tool to import all of our commits from the repository into git-stats.
The tool we need is called "git-stats-importer". We can install it globally using:
npm install -g git-stats-importer
After "git-stats-importer" is installed, cd into the repository you want stats for.
If you get an error that says "Cannot find any emails", like this
you will need to run the command again followed by a "-e" and the email you use to access the repository like so:
git-stats-importer -e email@example.com
After running that command you should see a bunch of import lines followed by an "info Done."
At this point, we have everything we need to check out our stats!
To see a contribution calendar (similar to GitHub's) in your terminal, type this command:
You'll see all of your contributions from the past year in the same format!
If you wanted to see all of the contributions for your entire team (instead of those from just yourself) you can run:
And finally, to see how you stand compared to the rest of your team with contributions, you can generate a pie chart in your terminal with the percentages of contributions by each author in the repository by running:
The result should be something similar to this!
How cool is that?! I like to keep track of how I'm doing and compare it year to year. Hopefully this can help you measure your goals and progress over the past year. 🙂