Skip to content

Instantly share code, notes, and snippets.

@jarthorn
Created March 31, 2016 17:13
Show Gist options
  • Save jarthorn/a07ffd65bd2fd421a0e8019e58a6c6e0 to your computer and use it in GitHub Desktop.
Save jarthorn/a07ffd65bd2fd421a0e8019e58a6c6e0 to your computer and use it in GitHub Desktop.
Print a histogram of merge commits by month for the current Git repository
#!/usr/bin/env ruby
TEMPFILE = "/tmp/git-merge-dates.txt"
`git log --merges --pretty=format:"%ci" --date=short > #{TEMPFILE}`
puts "MONTH,COMMITS"
(2011..2016).each do |year|
(1..12).each do |month|
pattern = year.to_s + "-" + sprintf("%02d", month)
result = `grep #{pattern} #{TEMPFILE} | wc -l`
puts pattern + "," + result.strip
end
end
`rm #{TEMPFILE}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment