2012-03-08 09:00:13 +01:00
|
|
|
package Gitolite::Test;
|
|
|
|
|
|
|
|
# functions for the test code to use
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#<<<
|
|
|
|
@EXPORT = qw(
|
|
|
|
try
|
|
|
|
put
|
2012-03-10 14:26:29 +01:00
|
|
|
text
|
2012-03-10 14:27:04 +01:00
|
|
|
dump
|
2012-03-14 10:59:44 +01:00
|
|
|
confreset
|
|
|
|
confadd
|
2012-03-15 06:10:27 +01:00
|
|
|
cmp
|
2012-03-08 09:00:13 +01:00
|
|
|
);
|
|
|
|
#>>>
|
|
|
|
use Exporter 'import';
|
|
|
|
use File::Path qw(mkpath);
|
|
|
|
use Carp qw(carp cluck croak confess);
|
|
|
|
|
2012-03-14 10:59:44 +01:00
|
|
|
use Gitolite::Common;
|
|
|
|
|
2012-03-08 09:00:13 +01:00
|
|
|
BEGIN {
|
|
|
|
require Gitolite::Test::Tsh;
|
2012-03-12 16:24:30 +01:00
|
|
|
*{'try'} = \&Tsh::try;
|
|
|
|
*{'put'} = \&Tsh::put;
|
2012-03-10 14:26:29 +01:00
|
|
|
*{'text'} = \&Tsh::text;
|
2012-03-15 15:34:30 +01:00
|
|
|
*{'cmp'} = \&Tsh::cmp;
|
2012-03-08 09:00:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
# required preamble for all tests
|
|
|
|
try "
|
|
|
|
DEF gsh = /TRACE: gsh.SOC=/
|
2012-03-09 03:59:41 +01:00
|
|
|
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;
|
2012-03-10 14:26:29 +01:00
|
|
|
DEF AP_2 = AP_1; git add conf ; ok; git commit -m %1; ok; /master.* %1/
|
2012-03-09 03:59:41 +01:00
|
|
|
DEF ADMIN_PUSH = AP_2 %1; glt push admin origin; ok; gsh; /master -> master/
|
|
|
|
|
2012-03-11 08:40:32 +01:00
|
|
|
DEF CS_1 = pwd; //tmp/tsh_tempdir.*gitolite-admin/; git remote -v; ok; /file://gitolite-admin/
|
2012-03-11 11:54:00 +01:00
|
|
|
DEF CHECK_SETUP = CS_1; git log; ok; /6b18ec2ab0f765122ec133959b36c57f77d4565c/
|
2012-03-11 08:40:32 +01:00
|
|
|
|
2012-03-20 11:45:55 +01:00
|
|
|
DEF CLONE = glt clone %1 file:///%2
|
|
|
|
DEF PUSH = glt push %1 origin
|
2012-03-11 08:40:32 +01:00
|
|
|
|
|
|
|
# clean install
|
2012-03-10 14:26:29 +01:00
|
|
|
mkdir -p $ENV{HOME}/bin
|
2012-04-11 15:36:07 +02:00
|
|
|
ln -sf $ENV{PWD}/t/glt ~/bin
|
|
|
|
./install -ln
|
2012-03-25 06:27:02 +02:00
|
|
|
cd; rm -vrf .gito* repositories
|
2012-03-11 11:54:00 +01:00
|
|
|
git config --global user.name \"gitolite tester\"
|
|
|
|
git config --global user.email \"tester\@example.com\"
|
2012-03-10 14:26:29 +01:00
|
|
|
|
2012-03-11 08:40:32 +01:00
|
|
|
# setup
|
2012-03-10 14:26:29 +01:00
|
|
|
gitolite setup -a admin
|
2012-03-11 08:40:32 +01:00
|
|
|
|
|
|
|
# clone admin repo
|
|
|
|
cd tsh_tempdir
|
|
|
|
glt clone admin --progress file://gitolite-admin
|
|
|
|
cd gitolite-admin
|
2012-03-10 14:26:29 +01:00
|
|
|
" or die "could not setup the test environment; errors:\n\n" . text() . "\n\n";
|
2012-03-08 09:00:13 +01:00
|
|
|
|
2012-03-10 14:27:04 +01:00
|
|
|
sub dump {
|
|
|
|
use Data::Dumper;
|
|
|
|
for my $i (@_) {
|
|
|
|
print STDERR "DBG: " . Dumper($i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-14 10:59:44 +01:00
|
|
|
sub _confargs {
|
2012-03-15 15:34:30 +01:00
|
|
|
return @_ if ( $_[1] );
|
2012-03-14 10:59:44 +01:00
|
|
|
return 'gitolite.conf', $_[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
sub confreset {
|
2012-03-17 12:22:36 +01:00
|
|
|
chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
|
2012-03-15 15:34:30 +01:00
|
|
|
system( "rm", "-rf", "conf" );
|
2012-03-14 10:59:44 +01:00
|
|
|
mkdir("conf");
|
2012-03-14 11:00:05 +01:00
|
|
|
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 ");
|
2012-03-21 14:51:12 +01:00
|
|
|
put "|cut -c9- > conf/gitolite.conf", '
|
2012-03-14 10:59:44 +01:00
|
|
|
repo gitolite-admin
|
|
|
|
RW+ = admin
|
|
|
|
repo testing
|
|
|
|
RW+ = @all
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
|
|
|
sub confadd {
|
2012-03-17 12:22:36 +01:00
|
|
|
chdir("../gitolite-admin") or die "in `pwd`, could not cd ../g-a";
|
2012-03-15 15:34:30 +01:00
|
|
|
my ( $file, $string ) = _confargs(@_);
|
2012-03-14 10:59:44 +01:00
|
|
|
put "|cat >> conf/$file", $string;
|
|
|
|
}
|
|
|
|
|
2012-03-08 09:00:13 +01:00
|
|
|
1;
|