Last active
December 18, 2015 05:09
-
-
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`
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
#!/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 |
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
git summary --since=6.months . | grep "^ " | awk '{total = total + $1}END{print total}' |
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
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