Giter Club home page Giter Club logo

git-hours's Introduction

Git hours

Build Status

Estimate time spent on a git repository.

For example time spent on Twitter's Bootstrap

โžœ  bootstrap git:(master) git hours
{

  ...

  "total": {
    "hours": 9959,
    "commits": 11470
  }
}

From a person working 8 hours per day, it would take more than 3 years to build Bootstrap.

Please note that the information might not be accurate enough to be used in billing.

Install

$ npm install -g git-hours

Has been tested and works with node 0.12, 4.x, 5.x, 6.x versions. Do not use node version below 0.12.

NOTE: If for some reason git hours won't work, try to npm install -g nodegit.

git-hours depends on nodegit. It might be a bit tricky to install. If installing git-hours fails for some reason, probably it was because nodegit couldn't be installed. Check their documentation for troubleshooting.

If the installation is too troublesome, you can try to install with Vagrant. It should work out of the box once you get the Vagrant correctly installed to your machine.

How it works

The algorithm for estimating hours is quite simple. For each author in the commit history, do the following:



Go through all commits and compare the difference between them in time.




If the difference is smaller or equal then a given threshold, group the commits to a same coding session.




If the difference is bigger than a given threshold, the coding session is finished.




To compensate the first commit whose work is unknown, we add extra hours to the coding session.




Continue until we have determined all coding sessions and sum the hours made by individual authors.


The algorithm in ~30 lines of code.

Usage

In root of a git repository run:

$ git hours

Note: repository is not detected if you are not in the root of repository!

Help

Usage: githours [options]

Options:

  -h, --help                                 output usage information
  -V, --version                              output the version number
  -d, --max-commit-diff [max-commit-diff]    maximum difference in minutes between commits counted to one session. Default: 120
  -a, --first-commit-add [first-commit-add]  how many minutes first commit of session should add to total. Default: 120
  -s, --since [since-certain-date]           Analyze data since certain date. [always|yesterday|tonight|lastweek|yyyy-mm-dd] Default: always'

Examples:

 - Estimate hours of project

     $ git hours

 - Estimate hours in repository where developers commit more seldom: they might have 4h(240min) pause between commits

     $ git hours --max-commit-diff 240

 - Estimate hours in repository where developer works 5 hours before first commit in day

     $ git hours --first-commit-add 300

 - Estimate hours work in repository since yesterday

   $ git hours --since yesterday

 - Estimate hours work in repository since 2015-01-31

   $ git hours --since 2015-01-31

For more details, visit https://github.com/kimmobrunfeldt/git-hours

Install with Vagrant

If you prefer to use vagrant, here's how:

Vagrant can be used to automatically set up a disposable Virtual Machine with the required environment and install the program.

$ git clone https://github.com/kimmobrunfeldt/git-hours
$ cd git-hours
$ vagrant up && vagrant ssh

And that's it, you can now test out git-hours. For example:

$ git clone https://github.com/twbs/bootstrap
$ cd bootstrap
$ git hours
{
  "total": {
    "hours": 6417,
    "commits": 9779
  }
}

Then when you are done playing around you can cleanly remove the vm from your system by running:

$ exit
$ vagrant destroy -f

Run with docker

Install docker and run the following command inside the git repo you want to analyze:

docker run --rm -v $(pwd):/code khor/git-hours

It mounts the current directory (pwd) inside the docker container and runs git hours on it.

git-hours's People

Contributors

crooy avatar fabiosoft avatar kh0r avatar kimmobrunfeldt avatar mrpjer avatar pieroblunda avatar qgustavor avatar vdloo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.