add a script to find large files in git repos
This commit is contained in:
parent
713c5a6dcd
commit
3983d45696
1 changed files with 23 additions and 0 deletions
23
git-large-files
Executable file
23
git-large-files
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env ruby -w
|
||||
head, treshold = ARGV
|
||||
head ||= 'HEAD'
|
||||
Megabyte = 1000 ** 2
|
||||
treshold = (treshold || 0.1).to_f * Megabyte
|
||||
|
||||
big_files = {}
|
||||
|
||||
IO.popen("git rev-list #{head}", 'r') do |rev_list|
|
||||
rev_list.each_line do |commit|
|
||||
commit.chomp!
|
||||
for object in `git ls-tree -zrl #{commit}`.split("\0")
|
||||
bits, type, sha, size, path = object.split(/\s+/, 5)
|
||||
size = size.to_i
|
||||
big_files[sha] = [path, size, commit] if size >= treshold
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
big_files.each do |sha, (path, size, commit)|
|
||||
where = `git show -s #{commit} --format='%h: %cr'`.chomp
|
||||
puts "%4.1fM\t%s\t(%s)" % [size.to_f / Megabyte, path, where]
|
||||
end
|
||||
Loading…
Reference in a new issue