Skip to content

Instantly share code, notes, and snippets.

@kwstannard
Created November 7, 2012 20:27
Show Gist options
  • Save kwstannard/4034191 to your computer and use it in GitHub Desktop.
Save kwstannard/4034191 to your computer and use it in GitHub Desktop.
function git_contributions() {
shortstat=$(git log --author=$1 --oneline --shortstat | grep deletions)
`/usr/bin/env ruby <<-RUBY
additions = 0
deletions = 0
%[ $shortstat ].each_line do |line|
addition_matches = line.match(/(\d+) insertions/)
additions += addition_matches[1].to_i if addition_matches
deletion_matches = line.match(/(\d+) deletions/)
deletions += deletion_matches[1].to_i if deletion_matches
end
puts "echo #{additions} added : #{deletions} deleted"
RUBY`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment