File: check-filesize-limit.pl

package info (click to toggle)
libsvn-hooks-perl 1.36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,365; makefile: 7
file content (18 lines) | stat: -rwxr-xr-x 541 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Check if every added/updated file is smaller than a fixed limit.

my $LIMIT = 10 * 1024 * 1024;	# 10MB

# Note that this need at least version 0.29 of SVN::Look, which
# implements method 'filesize', new with Subversion 1.7.0.

PRE_COMMIT {
    my ($svnlook) = @_;
    foreach my $file ($svnlook->added(), $svnlook->updated()) {
	next if $file =~ m:/$:; # skip directories
	my $size = $svnlook->filesize($file);
	die "Added file '$file' has $size bytes, more than our current limit of $LIMIT bytes.\n"
	    if $size > $LIMIT;
    }
};

1;