Created
January 21, 2016 13:57
-
-
Save corbt/633e018bc5636713cca0 to your computer and use it in GitHub Desktop.
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
# Counts the total number of insertions and deletions in a git repository's lifetime | |
require 'git' | |
repo = Git.open('../emberall') | |
prev = repo.log.first | |
deletions = 0 | |
insertions = 0 | |
repo.log(count = 5000).each do |commit| | |
source_file = /.*(rb)|(jsx)|(cljs)|(scss)|(yml)/ | |
stats_files = repo.diff(commit, prev).stats[:files] | |
.select { |f| f =~ source_file } | |
deletions += stats_files.inject(0) { |sum, f| sum + f.last[:deletions] } | |
insertions += stats_files.inject(0) { |sum, f| sum + f.last[:insertions] } | |
prev = commit | |
end | |
puts "Deletions: #{deletions}" | |
puts "Insertions: #{insertions}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment