Skip to content

Instantly share code, notes, and snippets.

@drnic
Last active December 18, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drnic/5730270 to your computer and use it in GitHub Desktop.
Save drnic/5730270 to your computer and use it in GitHub Desktop.
The number of commits in a repo (or subfolder). Uses `brew install git-extras`
#!/usr/bin/env ruby
initial_months_ago = ARGV.shift || 12
puts "Showing last #{initial_months_ago} months of commits per directory"
subfolders=Dir['*'].select { |dir| File.directory?(dir) }
def summary(dir, months_ago)
filter = "--since #{months_ago}.months --until #{months_ago - 1}.months"
`git summary #{filter} #{dir} | grep '^ ' | awk '{total = total + $1}END{print total}'`.strip
end
subfolders.each do |dir|
commit_counts = []
print "%23s" % dir
1.upto(initial_months_ago.to_i) do |months_ago|
print "\t#{summary dir, months_ago}"
end
puts ""
end
git summary --since=6.months . | grep "^ " | awk '{total = total + $1}END{print total}'
filter=$1 # e.g. '--since=6.months'
subfolders=$(ls -l | egrep '^d' | awk '{print $9}')
for dir in $subfolders
do
commitcount=$(git summary $filter $dir | grep "^ " | awk '{total = total + $1}END{print total}')
echo $dir $commitcount
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment