Git time tracking
#!/usr/bin/ruby
command = '/usr/bin/git --no-pager log --oneline'
ARGV.each do|a|
if a.match(/^--after/)
command += ' ' + a
end
end
hours = 0
begin
output = `#{command}`
commits = output.split("\n")
commits.each do |line|
line.scan(/t\[(.*)\]/) do |r|
r.each { |h| hours += h.to_f }
end
end
print "Total: #{hours}hrs\n"
rescue => e
puts e.message
exit
end
A script for time tracking using git commits.
- Save the script as an executable (I've called it git-tt)
- Add tags to your commit messages with the amount of hours you've spent, eg. "Implemented foobar feature t[1.5]."
- Run git tt from a git repo to show total hours for that repo.
- Add '--after="2010-03-15"' to show total for commits since the date
Written by Steve Halford
Related protips
1 Response
good tips ! thank's
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#