Created
May 15, 2011 10:19
-
-
Save ignacy/973028 to your computer and use it in GitHub Desktop.
Get git commit timmings
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
| require 'time' | |
| data = `git log | grep "^Date"`.split($/). | |
| map { |line| Time.parse(line.split(' ')[4]) }. | |
| group_by { |x| x.hour } | |
| data.each { |k, v| data[k] = data[k].size } | |
| total_commits = data.values.inject(0) { |sum, x| sum += x } | |
| data = data.sort { |a, b| a[0] <=> b[0] } | |
| puts "|---------------------------------" | |
| puts "| Total commits: #{total_commits.to_s.ljust(17)}" | |
| puts "|---------------------------------" | |
| puts "| Hour | #of Commits | %of Commits" | |
| puts "|---------------------------------" | |
| data.each do |k, v| | |
| puts "| #{k.to_s.ljust(5)}|#{v.to_s.center(13)}| #{"%.3f"%((v*100.0)/total_commits)}" | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.sort.group_by { |x| x.hour }should just be written as.group_by { |x| x.hour }. sort is unnecessary