Skip to content

Instantly share code, notes, and snippets.

@NilsHaldenwang
Created March 20, 2012 22:07
Show Gist options
  • Save NilsHaldenwang/2141763 to your computer and use it in GitHub Desktop.
Save NilsHaldenwang/2141763 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
changed_files = insertions = deletions = 0
cmd = nil
default_log_cmd = 'git log --since="00:00:01am" --stat -- .'
complete_log_cmd = 'git log --pretty=medium --stat -- .'
unless ARGV[0]
puts "No time given. Using default: today in current folder."
cmd = default_log_cmd
else
if ARGV[0] == "all"
puts "Showing all changes in the current folder."
cmd = complete_log_cmd
else
cmd = ARGV[0]
end
end
puts cmd
lines = `#{cmd}`
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
puts "#{changed_files} files changed, #{insertions} insertions(+), #{deletions} deletions(-) (#{insertions + deletions} changes)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment