File: 01-direct.t

package info (click to toggle)
libsvn-hooks-perl 1.36-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 380 kB
  • sloc: perl: 1,365; makefile: 7
file content (53 lines) | stat: -rwxr-xr-x 969 bytes parent folder | download | duplicates (5)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- cperl -*-

use strict;
use warnings;
use lib 't';
use Test::More;

require "test-functions.pl";

if (can_svn()) {
    plan tests => 2;
}
else {
    plan skip_all => 'Cannot find or use svn commands.';
}

my $t = reset_repo();

set_hook(<<'EOS');
START_COMMIT {
    my ($repos_path, $username, $capabilities) = @_;

    length $username
	or die "Empty username not allowed to commit.\n";
};

PRE_COMMIT {
    my ($svnlook) = @_;

    foreach my $added ($svnlook->added()) {
        warn "= $added\n";
	$added !~ /\.(exe|o|jar|zip)$/
	    or die "Please, don't commit binary files such as '$added'.\n";
    }
};
EOS

my $txtfile = catfile($t, 'wc', 'file.txt');

work_ok('setup', <<"EOS");
echo txt >$txtfile
svn add -q --no-auto-props $txtfile
svn ci -mx $txtfile
EOS

my $zipfile = catfile($t, 'wc', 'file.zip');

work_nok('binary' => 'Please, don\'t commit binary files', <<"EOS");
echo txt >$zipfile
svn add -q --no-auto-props $zipfile
svn ci -mx $zipfile
EOS