Tarrasch/dotfiles — comment on commit 0436de97fd204f8f8f01c2a746b11cf35e1ddc11
File:  line 0
By oleander:

Du får använda mitt nya [gg-kommando](https://github.com/oleander/dotfiles/blob/master/bin/gg-git). Bättre än någonsin. 17% av alla kommandon som används på min laptop är gg, (172 av 1000)

``` ruby
#!/usr/bin/env ruby -w

# GG git, version 0.2.0, 2012-01-25
# Warn you if you're trying to commit large files
# Usage: gg "A commit message"
# Copyright (c) 2012, Linus Oleander
# Released under the MIT licens

max_file_size = 0.2 # In MB

files = `git status --porcelain`.
split("\n").
map do |raw|
split = raw.split(" ")
media = split.last
type = split.first
if type == "??" and File.directory?(media)
next `find #{media} -type f`.gsub(%r{\/{2,}}, "/").split("\n")
end
media
end.
flatten.
map do |file|
next unless File.exists?(file)
size = File.new(file).size.to_f / (10**6)
next unless size > max_file_size
"#{file} (#{size.round(2)} MB)"
end.reject(&:nil?)

if files.any?
puts "#{files.count} large file(s) found."
puts files.join("\n")
puts "Continue?"
abort("Aborting") unless STDIN.gets =~ /y/
end

puts `git add . && git commit -v -a -m "#{ARGV.join(" ")}"`
```