blob: 904abbf11dd40bec8654bd9649a3709f67d162dc (
plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
package Gitolite::Test;
# functions for the test code to use
# ----------------------------------------------------------------------
#<<<
@EXPORT = qw(
try
put
text
lines
dump
confreset
confadd
cmp
md5sum
);
#>>>
use Exporter 'import';
use File::Path qw(mkpath);
use Carp qw(carp cluck croak confess);
use Digest::MD5 qw(md5_hex);
use Gitolite::Common;
BEGIN {
require Gitolite::Test::Tsh;
*{'try'} = \&Tsh::try;
*{'put'} = \&Tsh::put;
*{'text'} = \&Tsh::text;
*{'lines'} = \&Tsh::lines;
*{'cmp'} = \&Tsh::cmp;
}
use strict;
use warnings;
# ----------------------------------------------------------------------
# make sure the user is ready for it
if ( not $ENV{GITOLITE_TEST} or $ENV{GITOLITE_TEST} ne 'y' ) {
print "Bail out! See t/README for information on how to run the tests.\n";
exit 255;
}
# required preamble for all tests
try "
DEF gsh = /TRACE: gsh.SOC=/
DEF reject = /hook declined to update/; /remote rejected.*hook declined/; /error: failed to push some refs to/
DEF AP_1 = cd ../gitolite-admin; ok or die cant find admin repo clone;
DEF AP_2 = AP_1; git add conf ; ok; git commit -m %1; ok; /master.* %1/
DEF ADMIN_PUSH = AP_2 %1; glt push admin origin; ok; gsh; /master -> master/
DEF CS_1 = pwd; //tmp/tsh_tempdir.*gitolite-admin/; git remote -v; ok; /file:///gitolite-admin/
DEF CHECK_SETUP = CS_1; git log; ok; /fa7564c1b903ea3dce49314753f25b34b9e0cea0/
DEF CLONE = glt clone %1 file:///%2
DEF PUSH = glt push %1 origin
# clean install
mkdir -p $ENV{HOME}/bin
ln -sf $ENV{PWD}/t/glt ~/bin
./install -ln
cd; rm -vrf .gito* repositories
git config --file $ENV{HOME}/.gitconfig.local user.name \"gitolite tester\"
git config --file $ENV{HOME}/.gitconfig.local user.email \"tester\@example.com\"
git config --global include.path \"~/.gitconfig.local\"
# setup
gitolite setup -a admin
# clone admin repo
cd tsh_tempdir
glt clone admin --progress file:///gitolite-admin
cd gitolite-admin
" or die "could not setup the test environment; errors:\n\n" . text() . "\n\n";
sub dump {
use Data::Dumper;
for my $i (@_) {
print STDERR "DBG: " . Dumper($i);
}
}
sub _confargs {
return @_ if ( $_[1] );
return 'gitolite.conf', $_[0];
}
sub confreset {
chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
system( "rm", "-rf", "conf" );
mkdir("conf");
system("mv ~/repositories/gitolite-admin.git ~/repositories/.ga");
system("mv ~/repositories/testing.git ~/repositories/.te");
system("find ~/repositories -name '*.git' |xargs rm -rf");
system("mv ~/repositories/.ga ~/repositories/gitolite-admin.git");
system("mv ~/repositories/.te ~/repositories/testing.git ");
put "|cut -c9- > conf/gitolite.conf", '
repo gitolite-admin
RW+ = admin
repo testing
RW+ = @all
';
}
sub confadd {
chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
my ( $file, $string ) = _confargs(@_);
put "|cat >> conf/$file", $string;
}
sub md5sum {
my $out = '';
for my $file (@_) {
$out .= md5_hex( slurp($file) ) . " $file\n";
}
return $out;
}
1;
|