2012-03-08 09:00:13 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
# this is hardcoded; change it if needed
|
2012-03-10 14:26:29 +01:00
|
|
|
use lib "src";
|
2012-03-08 09:00:13 +01:00
|
|
|
use Gitolite::Test;
|
|
|
|
|
|
|
|
# basic tests
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
try "
|
2012-03-11 08:40:32 +01:00
|
|
|
plan 218
|
|
|
|
CHECK_SETUP
|
2012-03-08 09:00:13 +01:00
|
|
|
|
2012-03-09 03:59:41 +01:00
|
|
|
## subtest 1
|
2012-03-11 08:40:32 +01:00
|
|
|
cd ..
|
|
|
|
CLONE dev2 file://gitolite-admin ga2
|
2012-03-08 09:00:13 +01:00
|
|
|
!ok; gsh
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by fallthru/
|
2012-03-08 09:00:13 +01:00
|
|
|
/fatal: The remote end hung up unexpectedly/
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE admin --progress file://gitolite-admin ga2
|
2012-03-08 09:00:13 +01:00
|
|
|
ok; gsh
|
|
|
|
/Counting/; /Compressing/; /Total/
|
|
|
|
cd gitolite-admin; ok
|
|
|
|
";
|
|
|
|
|
|
|
|
put "conf/gitolite.conf", "
|
|
|
|
\@admins = admin dev1
|
|
|
|
repo gitolite-admin
|
|
|
|
- mm = \@admins
|
|
|
|
RW = \@admins
|
|
|
|
RW+ = admin
|
|
|
|
|
|
|
|
repo testing
|
|
|
|
RW+ = \@all
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
2012-03-09 03:59:41 +01:00
|
|
|
# push
|
2012-03-08 09:00:13 +01:00
|
|
|
git add conf; ok
|
|
|
|
git status -s; ok; /M conf/gitolite.conf/
|
|
|
|
git commit -m t01a; ok; /master.*t01a/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH dev2 origin; !ok; gsh
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by fallthru/
|
2012-03-08 09:00:13 +01:00
|
|
|
/fatal: The remote end hung up unexpectedly/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH admin origin; ok; /master -> master/
|
2012-03-08 09:00:13 +01:00
|
|
|
tsh empty; ok;
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH admin origin master:mm
|
2012-03-08 09:00:13 +01:00
|
|
|
!ok; gsh
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by refs/heads/mm/
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
2012-03-08 09:00:13 +01:00
|
|
|
";
|
|
|
|
|
|
|
|
put "conf/gitolite.conf", "
|
|
|
|
\@admins = admin dev1
|
|
|
|
repo gitolite-admin
|
|
|
|
RW+ = admin
|
|
|
|
|
|
|
|
repo testing
|
|
|
|
RW+ = \@all
|
|
|
|
|
|
|
|
repo t1
|
|
|
|
R = u2
|
|
|
|
RW = u3
|
|
|
|
RW+ = u4
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
2012-03-09 03:59:41 +01:00
|
|
|
## subtest 2
|
|
|
|
ADMIN_PUSH t01b
|
2012-03-08 09:00:13 +01:00
|
|
|
|
2012-03-09 03:59:41 +01:00
|
|
|
# clone
|
2012-03-08 09:00:13 +01:00
|
|
|
cd ..; ok;
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE u1 file://t1; !ok; gsh
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by fallthru/
|
2012-03-08 09:00:13 +01:00
|
|
|
/fatal: The remote end hung up unexpectedly/
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE u2 file://t1; ok; gsh
|
2012-03-08 09:00:13 +01:00
|
|
|
/warning: You appear to have cloned an empty repository./
|
|
|
|
ls -al t1; ok; /$ENV{USER}.*$ENV{USER}.*\.git/
|
|
|
|
cd t1; ok;
|
|
|
|
|
2012-03-09 03:59:41 +01:00
|
|
|
# push
|
2012-03-11 11:54:00 +01:00
|
|
|
test-commit tc1 tc2 tc2; ok; /a530e66/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u2 origin; !ok; gsh
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by fallthru/
|
2012-03-08 09:00:13 +01:00
|
|
|
/fatal: The remote end hung up unexpectedly/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 origin master; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/master -> master/
|
2012-03-08 09:00:13 +01:00
|
|
|
|
2012-03-09 03:59:41 +01:00
|
|
|
# rewind
|
2012-03-11 11:54:00 +01:00
|
|
|
reset-h HEAD^; ok; /HEAD is now at aa2b5c5 tc2/
|
|
|
|
test-tick; test-commit tc3; ok; /3ffced1/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 origin; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/rejected.*master -> master.*non-fast-forward./
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 -f origin; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
2012-03-09 09:03:32 +01:00
|
|
|
/DENIED by fallthru/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u4 origin +master; ok; gsh
|
2012-03-11 11:54:00 +01:00
|
|
|
/ \\+ a530e66...3ffced1 master -> master.*forced update./
|
2012-03-09 03:59:41 +01:00
|
|
|
";
|
|
|
|
|
|
|
|
put "../gitolite-admin/conf/gitolite.conf", "
|
|
|
|
\@admins = admin dev1
|
|
|
|
repo gitolite-admin
|
|
|
|
RW+ = admin
|
|
|
|
|
|
|
|
include 'i1.conf'
|
|
|
|
";
|
|
|
|
|
|
|
|
put "../gitolite-admin/conf/i1.conf", "
|
|
|
|
\@g1 = u1
|
|
|
|
\@g2 = u2
|
|
|
|
\@g3 = u3
|
|
|
|
\@gaa = aa
|
|
|
|
repo \@gaa
|
|
|
|
RW+ = \@g1
|
|
|
|
RW = \@g2
|
|
|
|
RW+ master = \@g3
|
|
|
|
RW master = u4
|
|
|
|
- master = u5
|
|
|
|
RW+ dev = u5
|
|
|
|
RW = u5
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
|
|
|
## subtest 3
|
|
|
|
ADMIN_PUSH t01c
|
|
|
|
|
|
|
|
cd ..; ok
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE u1 file://aa; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
cd aa; ok
|
|
|
|
test-commit set3 t1 t2 t3 t4 t5 t6 t7 t8 t9
|
|
|
|
ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u1 origin HEAD; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/To file://aa/
|
|
|
|
/\\* \\[new branch\\] HEAD -> master/
|
|
|
|
branch dev; ok
|
|
|
|
branch foo; ok
|
|
|
|
|
|
|
|
# u1 rewind master ok
|
|
|
|
reset-h HEAD^; ok
|
|
|
|
test-commit r1; ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u1 origin +master; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/To file://aa/
|
2012-03-11 11:54:00 +01:00
|
|
|
/\\+ 27ed463...05adfb0 master -> master .forced update./
|
2012-03-09 03:59:41 +01:00
|
|
|
|
|
|
|
# u2 rewind master !ok
|
|
|
|
reset-h HEAD^; ok
|
|
|
|
test-commit r2; ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u2 origin +master; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
|
|
|
|
|
|
|
# u3 rewind master ok
|
|
|
|
reset-h HEAD^; ok
|
|
|
|
test-commit r3; ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 origin +master; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/To file://aa/
|
2012-03-11 11:54:00 +01:00
|
|
|
/\\+ 05adfb0...6a532fe master -> master .forced update./
|
2012-03-09 03:59:41 +01:00
|
|
|
|
|
|
|
# u4 push master ok
|
|
|
|
test-commit u4; ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u4 origin master; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/To file://aa/
|
2012-03-11 11:54:00 +01:00
|
|
|
/6a532fe..f929773 +master -> master/
|
2012-03-09 03:59:41 +01:00
|
|
|
|
|
|
|
# u4 rewind master !ok
|
|
|
|
reset-h HEAD^; ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u4 origin +master; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
|
|
|
|
|
|
|
# u3,u4 push other branches !ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 origin dev; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u4 origin dev; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u3 origin foo; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u4 origin foo; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by fallthru/
|
|
|
|
|
|
|
|
# clean up for next set
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u1 -f origin master dev foo
|
2012-03-09 03:59:41 +01:00
|
|
|
ok; gsh
|
2012-03-11 11:54:00 +01:00
|
|
|
/f929773...6a532fe master -> master .forced update./
|
2012-03-09 03:59:41 +01:00
|
|
|
/new branch.*dev -> dev/
|
|
|
|
/new branch.*foo -> foo/
|
|
|
|
|
|
|
|
# u5 push master !ok
|
|
|
|
test-commit u5
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u5 origin master; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
reject
|
|
|
|
/DENIED by refs/heads/master/
|
|
|
|
|
|
|
|
# u5 rewind dev ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u5 origin +dev^:dev
|
2012-03-09 03:59:41 +01:00
|
|
|
ok; gsh
|
2012-03-11 11:54:00 +01:00
|
|
|
/\\+ 27ed463...1ad477a dev\\^ -> dev .forced update./
|
2012-03-09 03:59:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
# u5 rewind foo !ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u5 origin +foo^:foo
|
2012-03-09 03:59:41 +01:00
|
|
|
!ok; gsh
|
|
|
|
reject
|
|
|
|
/remote: FATAL: \\+ refs/heads/foo aa u5 DENIED by fallthru/
|
|
|
|
|
|
|
|
# u5 push foo ok
|
|
|
|
git checkout foo
|
|
|
|
/Switched to branch 'foo'/
|
|
|
|
|
|
|
|
test-commit u5
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u5 origin foo; ok; gsh
|
2012-03-11 11:54:00 +01:00
|
|
|
/27ed463..83da62c *foo -> foo/
|
2012-03-09 03:59:41 +01:00
|
|
|
|
|
|
|
# u1 delete dev ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u1 origin :dev; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/ - \\[deleted\\] *dev/
|
|
|
|
|
|
|
|
# push it back
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH u1 origin dev; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/\\* \\[new branch\\] *dev -> dev/
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
|
|
put "| cat >> ../gitolite-admin/conf/gitolite.conf", "
|
|
|
|
\@gr1 = r1
|
|
|
|
repo \@gr1
|
|
|
|
RW refs/heads/v[0-9] = u1
|
|
|
|
RW refs/heads = tester
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
|
|
|
## subtest 4
|
|
|
|
ADMIN_PUSH t01d
|
|
|
|
|
|
|
|
cd ..; ok
|
|
|
|
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE tester file://r1; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/Cloning into 'r1'.../
|
|
|
|
cd r1; ok
|
|
|
|
test-commit r1a r1b r1c r1d r1e r1f
|
|
|
|
ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH tester origin HEAD; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/\\* \\[new branch\\] *HEAD -> master/
|
|
|
|
git branch v1
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH tester origin v1; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/\\* \\[new branch\\] *v1 -> v1/
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
|
|
put "| cat >> ../gitolite-admin/conf/gitolite.conf", "
|
|
|
|
\@gr2 = r2
|
|
|
|
repo \@gr2
|
|
|
|
RW refs/heads/v[0-9] = u1
|
|
|
|
- refs/heads/v[0-9] = tester
|
|
|
|
RW refs/heads = tester
|
|
|
|
";
|
|
|
|
|
|
|
|
try "
|
|
|
|
## subtest 5
|
|
|
|
ADMIN_PUSH t01e
|
|
|
|
|
|
|
|
cd ..; ok
|
|
|
|
|
2012-03-11 08:40:32 +01:00
|
|
|
CLONE tester file://r2; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/Cloning into 'r2'.../
|
|
|
|
cd r2; ok
|
|
|
|
test-commit r2a r2b r2c r2d r2e r2f
|
|
|
|
ok
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH tester origin HEAD; ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/\\* \\[new branch\\] *HEAD -> master/
|
|
|
|
git branch v1
|
2012-03-11 08:40:32 +01:00
|
|
|
PUSH tester origin v1; !ok; gsh
|
2012-03-09 03:59:41 +01:00
|
|
|
/W refs/heads/v1 r2 tester DENIED by refs/heads/v\\[0-9\\]/
|
2012-03-08 09:00:13 +01:00
|
|
|
"
|