Skip to content

Instantly share code, notes, and snippets.

@neilvallon
Created July 27, 2014 07:45
Show Gist options
  • Save neilvallon/6a1535640806cd85f041 to your computer and use it in GitHub Desktop.
Save neilvallon/6a1535640806cd85f041 to your computer and use it in GitHub Desktop.
Count total line changes in a git repository.
#!/usr/bin/env ruby
log = `git log --oneline --shortstat`
puts log
i = 0
d = 0
log.each_line { |l|
ii = /([0-9]+) insertion/.match(l)
i += ii[1].to_i if ii
dd = /([0-9]+) deletion/.match(l)
d += dd[1].to_i if dd
}
puts "\nTotal: #{i} insertions, #{d} deletions"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment