Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.
/ git-hours Public archive

Count the time spent on code via git

License

Notifications You must be signed in to change notification settings

ceigh/git-hours

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-hours

Tool for count the time spent on code via git.

AUR version AUR last modified

Why

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.

Usage

TL;DR

git hours [-e email] [-d max_commits_difference_minutes] [-f first_commit_minutes] [file_name]

Details

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.

Algorithm

For detail explanation, you can see original git-hours HIW. I used similar method.

Installation

Package manager

For now, you can install it via AUR:

yay -S git-hours

Manual

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.

Configuration

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.

Contribution

If you find a bug or something, please open an issue.

License

GNU General Public License v3.0.