Tool for count the time spent on code via git.
Previously, I used git-hours tool, but due to the impossibility of a normal installation, and questionable work speed, it was decided to create my own utility.
Easy to use.
git hours [-e email] [-d max_commits_difference_minutes] [-f first_commit_minutes] [file_name]
Just call git hours
in repository directory. That's it. It automatically use your email from default .gitconfig
file, and count hours. Now you can see result:
git hours
me@org.com 16 19
Three columns: author email, total hours spended and total commits from this author.
If you don't have .gitconfig
file, you can create it, see git-config(1)
.
Also you can pass -e
flag to command, with desired email address:
git hours -e me@org.com
me@org.com 16 19
To specify path to repository, you can use git's -C
flag:
git -C /path/to/repo/ hours
me@org.com 16 19
Note that in first we pass flags for git
, and only then for hours
.
If you want to restrict calculations only for one specific file in repository:
git hours file_name
me@org.com 6 9
But it may be slow on repos with big amount of commits.
For more information check man git hours
.
For detail explanation, you can see original git-hours HIW. I used similar method.
For now, you can install it via AUR:
yay -S git-hours
As a main dependency i use libgit2, so you need to install it in your system first.
After it, you can just
git clone git@github.com:ceigh/git-hours.git
cd git-hours
make
sudo make install
To delete this program, call sudo make uninstall
.
To set your own minimal commits interval, use -d
key:
git hours -d 120 # stack commits only if between them <= 2 hours
-d
value must be number > 0.
Also you can change first commit balance time with -f
key:
git hours -f 120 # add 2 hours for every first commit in stack
-f
value must be number > 0.
By default both this values are 120
.
If you find a bug or something, please open an issue.
GNU General Public License v3.0.