/usr/share/doc/libsvn-hooks-perl/examples/check-java-style.pl is in libsvn-hooks-perl 1.27-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # Check if every added/changed Java file passes our code quality
# standards.
PRE_COMMIT {
my ($svnlook) = @_;
# CONFIG: Uncomment the following return to disable all checks
# return;
use autodie qw(:all);
use Cwd;
use File::Temp;
use IO::Handle;
my @javas = grep {/\.java$/} ($svnlook->added(), $svnlook->updated());
return unless @javas;
# CONFIG: Set $limit to 0 to have no limits on the number of files to be checked.
if (my $limit = 10) {
splice @javas, $limit if @javas > $limit;
}
# Create a copy of each java file in a temporary directory.
my $dir = File::Temp->newdir();
foreach my $java (@javas) {
(my $file = $java) =~ tr:/:_:; # flaten the java file name
open my $fh, '>', "$dir/$file";
$fh->print($svnlook->cat($java));
}
my $cwd = cwd();
chdir '/ha/subversion/admin/hooks/dsb';
# Invoke the code quality tool on all saved java files
system('java', '-jar', 'code-quality-hook-1.0-SNAPSHOT.jar', glob("$dir/*.java"));
chdir $cwd;
};
1;
|