A Go implementation of a tool to estimate time spent on a git repository based on commit history.
go install github.com/trinhminhtriet/git-hours@latestgit-hours [options]-max-commit-diff: Maximum difference in minutes between commits counted to one session (default: 120)-first-commit-add: How many minutes first commit of session should add to total (default: 120)-since: Analyze data since certain date [always|yesterday|today|lastweek|thisweek|yyyy-mm-dd] (default: always)-until: Analyze data until certain date [always|yesterday|today|lastweek|thisweek|yyyy-mm-dd] (default: always)-merge-request: Include merge requests into calculation (default: true)-path: Git repository to analyze (default: ".")-branch: Analyze only data on the specified branch (default: all branches)
- Estimate hours of project:
git-hours- Estimate hours in repository where developers commit more seldom (4h 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 specific date:
git-hours --since 2015-01-31- Estimate hours work in repository on the "master" branch:
git-hours --branch masterThe tool outputs JSON with the following structure:
{
"author@email.com": {
"name": "Author Name",
"hours": 42,
"commits": 100
},
"total": {
"hours": 42,
"commits": 100
}
}- Cannot analyze shallow copies. Run
git fetch --unshallowfirst if needed. - Time estimation is based on commit dates and configured time windows
- Merge commits can be excluded from the calculation
We welcome contributions!
- Fork this repository;
- Create a branch with your feature:
git checkout -b my-feature; - Commit your changes:
git commit -m "feat: my new feature"; - Push to your branch:
git push origin my-feature.
Once your pull request has been merged, you can delete your branch.
This project is licensed under the MIT License - see the LICENSE file for details.