repo-specific hooks: fix bug in handling reserved hooks
[gitolite.git] / t / branch-perms.t
blobe59baeabbd93b4bc7db5e2b8d6fcaacbc9fa69fe
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;
9 # branch permissions test
10 # ----------------------------------------------------------------------
12 try "plan 82";
14 confreset;confadd '
15 @g1 = u1
16 @g2 = u2
17 @g3 = u3
18 @gaa = aa
19 repo @gaa
20 RW+ = @g1
21 RW = @g2
22 RW+ master = @g3
23 RW master = u4
24 - master = u5
25 RW+ dev = u5
26 RW = u5
30 try "ADMIN_PUSH set1; !/FATAL/" or die text();
32 try "
33 cd ..; ok
34 glt clone u1 file:///aa; ok
35 cd aa; ok
36 tc l-995 l-996 l-997 l-998 l-999 l-1000 l-1001 l-1002 l-1003;
37 ok; /master a788db9. l-1003/
38 glt push u1 origin HEAD; ok; /To file:///aa/
39 /\\* \\[new branch\\] HEAD -> master/
41 git branch dev; ok
42 git branch foo; ok
44 # u1 rewind master succeed
45 git reset --hard HEAD^; ok; /HEAD is now at 65d5f4a l-1002/
46 tc v-865; ok; /master 3053bb4. v-865/
47 glt push u1 origin +master; ok; /\\+ a788db9...3053bb4 master -> master \\(forced update\\)/
49 # u2 rewind master fail
50 git reset --hard HEAD^; ok; /HEAD is now at 65d5f4a l-1002/
51 tc s-361; ok; /master b331651. s-361/
52 glt push u2 file:///aa +master; !ok; reject
53 /\\+ refs/heads/master aa u2 DENIED by fallthru/
55 # u3 rewind master succeed
56 git reset --hard HEAD^; ok
57 tc m-508; ok
58 glt push u3 file:///aa +master; ok; /\\+ .* master -> master \\(forced update\\)/
60 # u4 push master succeed
61 tc f-526; ok;
62 glt push u4 file:///aa master; ok; /master -> master/
64 # u4 rewind master fail
65 git reset --hard HEAD^; ok;
66 glt push u4 file:///aa +master; !ok; /\\+ refs/heads/master aa u4 DENIED by fallthru/
68 # u3 and u4 / dev foo -- all 4 fail
69 glt push u3 file:///aa dev; !ok; /W refs/heads/dev aa u3 DENIED by fallthru/
70 glt push u4 file:///aa dev; !ok; /W refs/heads/dev aa u4 DENIED by fallthru/
71 glt push u3 file:///aa foo; !ok; /W refs/heads/foo aa u3 DENIED by fallthru/
72 glt push u4 file:///aa foo; !ok; /W refs/heads/foo aa u4 DENIED by fallthru/
74 # clean up for next set
75 glt push u1 -f origin master dev foo
78 # u5 push master fail
79 tc l-417; ok
80 glt push u5 file:///aa master; !ok; /W refs/heads/master aa u5 DENIED by refs/heads/master/
82 # u5 rewind dev succeed
83 glt push u5 file:///aa +dev^:dev
84 ok; /\\+ .* dev\\^ -> dev \\(forced update\\)/
86 # u5 rewind foo fail
87 glt push u5 file:///aa +foo^:foo
88 !ok; /\\+ refs/heads/foo aa u5 DENIED by fallthru/
90 # u5 tries to push foo; succeeds
91 git checkout foo; ok; /Switched to branch 'foo'/
93 # u5 push foo succeed
94 tc e-530; ok;
95 glt push u5 file:///aa foo; ok; /foo -> foo/
97 # u1 delete branch dev succeed
98 glt push u1 origin :dev; ok; / - \\[deleted\\] *dev/
100 # quietly push it back again
101 glt push u1 origin dev; ok; / * \\[new branch\\] dev -> dev/
105 confadd '
106 repo @gaa
107 RWD dev = u4
110 try "ADMIN_PUSH set2; !/FATAL/" or die text();
112 try "
113 # u1 tries to delete dev on a new setup
114 cd ../aa; ok; /master -> master/
116 # u1 delete branch dev fail
117 glt push u1 origin :dev; !ok; /D refs/heads/dev aa u1 DENIED by fallthru/
119 # u4 delete branch dev succeed
120 glt push u4 file:///aa :dev; ok; / - \\[deleted\\] *dev/