Skip to content

Instantly share code, notes, and snippets.

@shayanbo
Created June 25, 2016 06:37
Show Gist options
  • Save shayanbo/3224728be17a313a76a7a926a2ca9912 to your computer and use it in GitHub Desktop.
Save shayanbo/3224728be17a313a76a7a926a2ca9912 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
oldCommit = ARGV[0]
newCommit = ARGV[1]
puts "Analysing..."
commits=`git rev-list #{oldCommit}..#{newCommit}`.split
binary_infos = []
additionSize=0
deletionSize=0
commits.each { |commit|
diffs = `git diff #{commit}~1..#{commit} --stat`.split("\n")
diffs.each { |diff_line|
snippets = diff_line.split(" ").reverse
isBin = (snippets[0] == 'bytes' && snippets[2] == '->')
if isBin
isAddition = (snippets[3] == '0')
bin_path = snippets[6..-1].reverse.join
bin_size = isAddition ? snippets[1].to_i : snippets[3].to_i
additionSize += bin_size if isAddition
deletionSize += bin_size unless isAddition
if isAddition
puts "New File #{bin_path} , Size is #{bin_size}"
else
puts "Deleted File #{bin_path} , Size is #{bin_size}"
end
end
}
}
puts(additionSize - deletionSize)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment