Created
June 21, 2015 18:46
-
-
Save kvz/bbb61b61e4ffab48e7f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Git Timetracker. Copyright Kevin van Zonneveld (kvz.io) | |
# License under MIT | |
# | |
# This file | |
# | |
# - can be run inside a git repository to get a list on what hours work took place (for billing) | |
# - takes 1 argument: since. It defaults to "2 months" | |
# | |
# Usage: | |
# | |
# cd repo | |
# git-timetracker.sh 1 month | |
# | |
# Remarks: | |
# | |
# - Since we can't use a custom dateformat but really want to, the hack is to | |
# use iso format, and add backspace characters (%x08) | |
# | |
# Possible output: | |
# | |
# 2013-03-30 14:02 4bf9607 kevin@vanzonneveld.net Allow the egrep to fail without bailing out | |
# 2013-03-28 01:29 9120b9e kevin@vanzonneveld.net When cron fails, fallback to fallback nameservers :) Fixes #1 | |
# 2013-03-27 13:42 d0b0df2 kevin@vanzonneveld.net Improve docs | |
# 2013-03-27 13:10 68c4314 kevin@vanzonneveld.net Initial import of dns-failover.sh | |
set -o pipefail | |
set -o errexit | |
set -o nounset | |
# set -o xtrace | |
# Optionally set how long to travel back in time | |
since="${@:-2 months}" | |
git --no-pager log \ | |
--date=iso \ | |
--since="${since}" \ | |
--date-order \ | |
--full-history \ | |
--all \ | |
--pretty=tformat:"%C(cyan)%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08 %C(bold red)%h %C(bold blue)%<(22)%ae %C(reset)%s" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A nice trick is to add it to your
~/.gitconfig
as an alias:You can then type
git timetrack
,git timetrack "1 day"
,git timetrack "1 month" --reverse
(the arguments are positional, so the duration is required in this case) in any git repository!