bdelespierre / gitstats
Iterate through git commits to gather statistics
2.5.0
2021-04-08 19:48 UTC
Requires
- php: ^7.4|^8.0
- symfony/console: ^5.2
- symfony/process: ^5.2
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.3
- scrutinizer/ocular: ^1.8
README
Rewinds your Git history to compute stats.
Installation
composer global require bdelespierre/gitstats
Add composer global vendor/bin directory to your PATH
Best way to do it is to add these lines to your ~/.profile
:
# Composer 1 global vendor/bin to PATH if [ -d "$HOME/.composer/vendor/bin" ] ; then PATH="$PATH:$HOME/.composer/vendor/bin" fi # Composer 2 global vendor/bin to PATH if [ -d "$HOME/.config/composer/vendor/bin" ] ; then PATH="$PATH:$HOME/.config/composer/vendor/bin" fi export PATH
Usage
Add a .gitstats.php
file in your project root directory:
<?php return [ 'tasks' => [ 'Commit message' => "git log -1 --pretty=%B | head -n 1", 'Commit author' => "git log -1 --pretty=%an", 'Number of files' => "find . -type f | wc -l", 'Number of directories' => "find . -type d | wc -l", ], ];
Run the application:
gitstats run
The output is formatted as CSV:
commit,date,"Commit message","Commit author","Number of files","Number of directories"
0e75bcac756226986f9e6ba745c0f1944ee482db,"2021-04-01 12:40:04","Major refactoring","Benjamin Delespierre",1647,398
1cd263613b1b3bb96bff86a04c0e0c42c9427f32,"2018-01-14 11:15:16","Add progress screenshot","Matthieu Napoli",1649,396
3159438bd963174acac8518d9d58e85fc5fb431f,"2018-01-10 11:48:56","Restrict dependencies correctly","Matthieu Napoli",1649,396
2dd0cf355552553eebc3614ada24c305393c628c,"2018-01-10 11:48:09","Show a progress bar","Matthieu Napoli",1649,396
a731d6c9d91c8e4f07db0bec6e22c912a55baef2,"2017-10-22 18:02:03","MIT License","Matthieu Napoli",1649,396
...
You can write the output to a file:
gitstats run > gistats.csv
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.