Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 31 lines (22 sloc) 766 Bytes
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use List::Util qw(max);
my $levels = shift || 1;
my $options = shift || ''; # e.g. --not --in=here
my %size;
open my $annex_find, "git annex find $options . --format '\${bytesize}\\t\${file}\\n' |";
while (my $line = <$annex_find>) {
chomp $line;
# Discard other git-annex output
next unless $line =~ /^[0-9]+\t/;
my ($bytesize, $file) = split /\t/, $line;
my @fragments = $file =~ m<([^/]+)>g;
splice @fragments, $levels if @fragments > $levels;
$size{join "/", @fragments} += $bytesize;
}
my $max_key_length = max( map { length } values %size );
for my $key (sort { $size{$b} <=> $size{$a} } keys %size) {
printf "%-${max_key_length}d\t%s\n", $size{$key}, $key;
}