2017 © Pedro Peláez
 

library gitstats

Iterate through git commits to gather statistics

image

mnapoli/gitstats

Iterate through git commits to gather statistics

  • Sunday, January 14, 2018
  • by mnapoli
  • Repository
  • 1 Watchers
  • 7 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Iterate through git commits to gather statistics

Installation

  • clone this repository
  • install Composer dependencies
  • symlink the gitstats to your /usr/local/bin: ln -s /home/<you>/code/gitstats/gitstats /usr/local/bin/gitstats

Alternatively you can install the Composer package globally (composer global require mnapoli/gitstats), (*1)

Usage

  • Add a .gitstats.yml file in your current directory:
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 | xargs"
    'Number of directories': "find . -type d | wc -l | xargs"
  • Run the application:
$ gitstats run <git-repository-url>

The repository will be cloned in a temporary directory. All tasks will be run against each commit. Ensure the repository doesn't contain modifications., (*2)

The output is formatted as CSV:, (*3)

Commit,Date,Number of files,Number of directories
d612a29fae3b0f625b9be819802e93214d4eecd9,2016-08-31T12:55:38+02:00,61,28
497f22a27896d146a35660f452eba24d3a14db3f,2016-08-31T12:53:01+02:00,61,28
fc0646f236e6bb0a10b14a67424f932f28eb1062,2016-08-26T19:29:40+02:00,62,28
221528e63d7aac3aa247dfde191b5f6c380cbb7e,2016-08-25T01:28:55+02:00,62,28
...

You can write the output to a file:, (*4)

$ gitstats run <git-repository-url> > results.csv

You can then import that into a database or open it up with Excel or whatever., (*5)

MySQL

You can output the result as SQL queries to insert/update a MySQL table:, (*6)

$ gitstats run <git-repository-url> --format=sql | mysql -u <user> -p <table>

Limit the number of commits processed

You can limit the number of commits to process using the --max parameter:, (*7)

# Process only 100 commits
$ gitstats run <git-repository-url> --max=100

Show the progress

You can show a progress bar on stderr using the --progress parameter. When using that parameter it makes sense to redirect the output to a file or another command:, (*8)

$ gitstats run <git-repository-url> --progress > file.csv

, (*9)

The Versions

14/01 2018

dev-master

9999999-dev

Iterate through git commits to gather statistics

  Sources   Download

MIT

The Requires

 

10/01 2018

0.1.1

0.1.1.0

Iterate through git commits to gather statistics

  Sources   Download

MIT

The Requires