Last active
December 19, 2015 06:09
-
-
Save swistak/5909035 to your computer and use it in GitHub Desktop.
Working bee.
This file contains hidden or 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
# Helpful reference http://alexpeattie.com/blog/working-with-dates-in-git/ | |
require 'date' | |
require 'pp' | |
cmd="git log --author='#{ARGV[0]}' --abbrev-commit --format=medium --date=iso" | |
cmd+= " --since=#{Date.parse(ARGV[1]).to_s}" if ARGV[1] | |
cmd+= " --until=#{Date.parse(ARGV[2]).to_s}" if ARGV[2] | |
e = e = <<GIT | |
commit eca3dae | |
Author: Marcin Raczkowski <[email protected]> | |
Date: 2013-06-03 18:46:29 +0200 | |
Adding default ordering for content_parts | |
GIT | |
puts cmd | |
commits = `#{cmd}` | |
commit = nil | |
author = nil | |
date = nil | |
desc = [] | |
by_date = Hash.new{|h,k| h[k] = []} | |
since = Date.today | |
commits.split(/\n/).each do |line| | |
case line | |
when /^commit (\w+)/ | |
if commit | |
since = date if since > date | |
by_date[date] << {commit: commit, author: author, date: date, desc: desc} | |
author = nil; date = nil; desc = [] | |
end | |
commit = $1 | |
when /^Author: (.+)/ | |
author = $1 | |
when /^Date: (.+)/ | |
date = Date.parse($1) | |
else | |
if commit | |
desc << line | |
end | |
end | |
end | |
(since..Date.today).each do |cdate| | |
if cdate.wday == 0 || cdate == since # Sunday | |
# Week adjustment is of course working only for 2013 and 9 is a week of start of project. | |
# needs to be adjusted per project of course. | |
puts "=== Week: #{(cdate.yday - 6) / 7 - 9}" | |
end | |
if (cs = by_date[cdate]) && cs.length > 0 | |
puts cdate.strftime("%Y-%m-%d %A") + " - #{cs.length} commits" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment