5 # this is hardcoded; change it if needed
9 # test script for partial copy feature
10 # ----------------------------------------------------------------------
14 my $rb = `gitolite query-rc -n GL_REPO_BASE`;
16 try
'cd tsh_tempdir; mkdir -p local/hooks/repo-specific';
18 foreach my $h (qw
/first second/) {
19 put
"local/hooks/repo-specific/$h", "#!/bin/sh
21 if [ \$# -ne 0 ]; then
22 echo \$0 has args: \$@
24 echo \$0 has stdin: `cat`
28 try
'chmod +x local/hooks/repo-specific/*';
31 my $tempdir = join("\n", sort (lines
()));
32 try
'cd gitolite-admin';
34 try
"# Enable LOCAL_CODE and repo-specific-hooks
36 perl s/# 'repo-specific-hooks'/'repo-specific-hooks'/
37 perl s%# LOCAL_CODE%LOCAL_CODE => '$tempdir/local', #%
55 try
"ADMIN_PUSH repo-specific-hooks-0; !/FATAL/" or die text
();
58 /Init.*empty.*foo\\.git/
59 /Init.*empty.*bar\\.git/
60 /Init.*empty.*baz\\.git/
61 /Init.*empty.*frob\\.git/
64 my $failing_hook = "#!/bin/sh
68 # Place a existing hooks in repos
69 put
"$rb/foo.git/hooks/post-recieve", $failing_hook;
70 put
"$rb/bar.git/hooks/pre-recieve", $failing_hook;
71 put
"$rb/baz.git/hooks/post-update", $failing_hook;
72 put
"$rb/frob.git/hooks/post-update", $failing_hook;
75 ls -l $rb/foo.git/hooks/*; ok; !/post-receive -. .*local/hooks/multi-hook-driver/
76 ls -l $rb/bar.git/hooks/*; ok; !/pre-receive -. .*local/hooks/multi-hook-driver/
77 ls -l $rb/baz.git/hooks/*; ok; !/post-update -. .*local/hooks/multi-hook-driver/
78 ls -l $rb/frob.git/hooks/*; ok; !/post-update -. .*local/hooks/multi-hook-driver/
84 option hook.post-receive = first
88 option hook.pre-receive = first second
92 option hook.post-receive = first
93 option hook.post-update = first second
97 option hook.post-receive.b = first
98 option hook.post-receive.a = second
101 option hook.post-receive = second
105 try
"ADMIN_PUSH repo-specific-hooks-1; !/FATAL/" or die text
();
108 ls -l $rb/foo.git/hooks/*; ok; /post-receive.h00-first/
110 /post-receive -. .*local/hooks/multi-hook-driver/
111 ls -l $rb/bar.git/hooks/*; ok; /pre-receive.h00-first/
112 /pre-receive.h01-second/
113 /pre-receive -. .*local/hooks/multi-hook-driver/
114 ls -l $rb/baz.git/hooks/*; ok; /post-receive.h00-first/
115 /post-update.h00-first/
116 /post-update.h01-second/
117 /post-update -. .*local/hooks/multi-hook-driver/
118 ls -l $rb/frob.git/hooks/*; ok; /post-receive.h00-second/
119 /post-receive.h01-first/
120 /post-receive -. .*local/hooks/multi-hook-driver/
121 ls -l $rb/gitolite-admin.git/hooks/*
123 /post-receive -. .*local/hooks/multi-hook-driver/
124 !/post-update -. .*local/hooks/multi-hook-driver/
130 # Single hook still works
132 CLONE admin foo; ok; /empty/; /cloned/
135 PUSH admin master; ok; /new.*master -. master/
136 /hooks/post-receive.h00-first/
137 !/post-receive.*has args:/
138 /post-receive.h00-first has stdin: 0000000000000000000000000000000000000000 ee47f8b6be2160ad1a3f69c97a0cb3d488e6657e refs/heads/master/
142 # Multiple hooks fired
144 CLONE admin bar; ok; /empty/; /cloned/
147 PUSH admin master; ok; /new.*master -. master/
148 /hooks/pre-receive.h00-first/
149 !/hooks/pre-recieve.*has args:/
150 /hooks/pre-receive.h00-first has stdin: 0000000000000000000000000000000000000000 cfc8561c7827a8b94df6c5dad156383d4cb210f5 refs/heads/master/
151 /hooks/pre-receive.h01-second/
152 !/hooks/pre-receive.h01.*has args:/
153 /hooks/pre-receive.h01-second has stdin: 0000000000000000000000000000000000000000 cfc8561c7827a8b94df6c5dad156383d4cb210f5 refs/heads/master/
157 # Post-update has stdin instead of arguments
159 CLONE admin baz; ok; /empty/; /cloned/
162 PUSH admin master; ok; /new.*master -. master/
163 /hooks/post-receive.h00-first/
164 !/hooks/post-receive.h00.*has args:/
165 /hooks/post-receive.h00-first has stdin: 0000000000000000000000000000000000000000 28636171ae703f42fb17c312c6b6a078ed07a2cd refs/heads/master/
166 /hooks/post-update.h00-first/
167 /hooks/post-update.h00-first has args: refs/heads/master/
168 !/hooks/post-update.h00.*has stdin:/
169 /hooks/post-update.h01-second/
170 /hooks/post-update.h01-second has args: refs/heads/master/
171 !/hooks/post-update.h01.*has stdin:/
174 # Verify hooks are removed properly
179 option hook.post-receive =
183 option hook.pre-receive = second
187 option hook.post-receive =
188 option hook.post-update = second
191 try
"ADMIN_PUSH repo-specific-hooks-02; !/FATAL/" or die text
();
194 ls $rb/foo.git/hooks/*; ok; !/post-receive/
195 ls $rb/bar.git/hooks/*; ok; !/pre-receive.*first/
196 /pre-receive.h00-second/
197 ls $rb/baz.git/hooks/*; ok; !/post-receive/
198 !/post-update.*first/
199 /post-update.h00-second/
208 PUSH admin master; ok; /master -. master/
209 !/hooks/post-receive/
213 # Bar only has the second hook
216 PUSH admin master; ok; /master -. master/
217 /hooks/pre-receive.h00-second/
218 !/hooks/pre-receive.*has args:/
219 /hooks/pre-receive.h00-second has stdin: 0000000000000000000000000000000000000000 cc7808f77c7c7d705f82dc54dc3152146175768f refs/heads/master/
223 # Baz has no post-receive and keeps the second hook for post-update
226 PUSH admin master; ok; /master -. master/
227 !/hooks/post-receive.*/
228 /hooks/post-update.h00-second/
229 /hooks/post-update.h00-second has args: refs/heads/master/
230 !/hooks/post-update.*has stdin/