keeping the profs at Cambridge happy...
[gitolite.git] / t / fork.t
blob2a7a7b7dc73e0f11879c324056b29b5c1c1d109d
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 # this is hardcoded; change it if needed
6 use lib "src/lib";
7 use Gitolite::Test;
8 my $h = $ENV{HOME};
10 # fork command
11 # ----------------------------------------------------------------------
13 try "plan 38";
15 my $rb = `gitolite query-rc -n GL_REPO_BASE`;
17 confreset;confadd '
19 repo foo/CREATOR/..*
20 C = u1 u2
21 RW+ = CREATOR
24 try "ADMIN_PUSH set1; !/FATAL/" or die text();
26 try "
27 cd ..
29 # make the initial repo
30 glt ls-remote u1 file:///foo/u1/u1a;ok; gsh
31 /Initialized empty Git repository in .*/foo/u1/u1a.git/
32 # vrc doesn't have the fork command
33 glt fork u1 foo/u1/u1a foo/u1/u1a2; !ok; /FATAL: unknown git/gitolite command: \\'fork/
36 # allow fork as a valid command
37 $ENV{G3T_RC} = "$ENV{HOME}/g3trc";
38 put "$ENV{G3T_RC}", "\$rc{COMMANDS}{fork} = 1;\n";
40 # enable set-default-roles feature, add options, push
41 try "
42 cat $h/.gitolite.rc
43 perl s/# 'set-default-roles'/'set-default-roles'/
44 put $h/.gitolite.rc
46 try "cd gitolite-admin";
47 confadd '
48 repo foo/CREATOR/..*
49 C = u1 u2
50 RW+ = CREATOR
51 option default.roles-1 = READERS @all
53 try "ADMIN_PUSH set1; !/FATAL/" or die text();
54 try "cd ..";
56 try "
57 # now the fork succeeds
58 glt fork u1 foo/u1/u1a foo/u1/u1a2; ok; /Cloning into bare repository '.*/foo/u1/u1a2.git'/
59 /foo/u1/u1a forked to foo/u1/u1a2/
61 # now the actual testing starts
62 # read error
63 glt fork u1 foo/u1/u1c foo/u1/u1d; !ok; /'foo/u1/u1c' does not exist or you are not allowed to read it/
64 glt fork u2 foo/u1/u1a foo/u1/u1d; !ok; /'foo/u1/u1a' does not exist or you are not allowed to read it/
66 # write error
67 glt fork u1 foo/u1/u1a foo/u2/u1d; !ok; /'foo/u2/u1d' already exists or you are not allowed to create it/
69 # no error
70 glt fork u1 foo/u1/u1a foo/u1/u1e; ok; /Cloning into bare repository '.*/foo/u1/u1e.git'/
71 /warning: You appear to have cloned an empty repository/
72 /foo/u1/u1a forked to foo/u1/u1e/
73 # both exist
74 glt fork u1 foo/u1/u1a foo/u1/u1e; !ok; /'foo/u1/u1e' already exists or you are not allowed to create it/
77 # now check the various files that should have been produced
79 my $t;
80 try "cd $rb; find . -name gl-perms"; $t = md5sum(sort (lines())); cmp $t,
81 '59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
82 59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1e.git/gl-perms
85 try "cd $rb; find . -name gl-creator"; $t = md5sum(sort (lines())); cmp $t,
86 'e4774cdda0793f86414e8b9140bb6db4 ./foo/u1/u1a.git/gl-creator
87 346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1a2.git/gl-creator
88 346955ff2eadbf76e19373f07dd370a9 ./foo/u1/u1e.git/gl-creator