Created
February 23, 2015 11:47
-
-
Save rilian/209917e0204b15807038 to your computer and use it in GitHub Desktop.
calculate days of work by developer from git repo
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
# | |
# In git project folder run | |
# git log > log.txt | |
# | |
# then | |
# ruby git_work_by_day.rb | |
# | |
# Sample result: | |
# | |
# Fri Feb 20 => Mike Smith, Bob Jones | |
# Thu Feb 19 => Bob Jones, Tom Doe | |
# Wed Feb 18 => Tom Doe | |
# | |
log = File.read('log.txt') | |
works = {} | |
log.lines.each do |line| | |
md = line.match(/\(([\w\s]+)\).*([A-Z]\w{2}\s[A-Z]\w{2}\s\d+)/) | |
name = md[1] | |
date = md[2] | |
works[date] = [] if works[date].nil? | |
works[date] << name | |
works[date] = works[date].uniq | |
end | |
works.each do |date, names| | |
puts "#{date} => #{names.join(', ')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment