Skip to content

Instantly share code, notes, and snippets.

@NilsHaldenwang
Created September 3, 2011 15:11
Show Gist options
  • Save NilsHaldenwang/1191320 to your computer and use it in GitHub Desktop.
Save NilsHaldenwang/1191320 to your computer and use it in GitHub Desktop.
This script outputs the sum of the git changes you made today.
#!/usr/bin/env ruby
changed_files = insertions = deletions = 0
lines = `git log --since="0am" --stat`
lines.each_line do |line|
if line =~ /(\d+) files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)/
changed_files += $1.to_i
insertions += $2.to_i
deletions += $3.to_i
end
end
branch = `git name-rev --name-only HEAD`
puts "Today you made the following changes on the branch '#{branch.chomp}':"
puts "#{changed_files} files changed, #{insertions} insertions(+), #{deletions} deletions(-)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment