create command: remove race condition...
[gitolite.git] / t / refex-expr-test-9
blobb3a9f09417479b3908b03f5615eb33c129f7662e
1 #!/bin/bash
3 # not part of the official test suite (yet); just some q&d testing
5 # to be run from ~/gitolite as ./$0
7 set -e
8 exec 3>&2
9 exec > /dev/null
10 exec 2> /dev/null
11 print2() { echo -n "$@" >&3; }
12 say2() { echo "$@" >&3; }
13 die() { echo FATAL: "$@" >&3; exit 1; }
15 export od=$PWD
16 export tmp=$(mktemp -d)
17 echo $tmp >&3
18 trap "rm -rf $tmp" 0
19 cd $tmp
21 print2 setting up...
22 ( cd $od; t/reset )
23 echo "push @{ \$RC{ENABLE} }, 'refex-expr';" >> ~/.gitolite.rc
24 cat <<EOF >> ~/.gitolite/conf/gitolite.conf
26 repo r9
28 RW+ = u3 u4
30 # u1 and u2 have some restrictions
32 # cant push master
33 - master = u1 u2
34 # cant push versioned tags, but other tags are fine
35 - refs/tags/v[0-9] = u1 u2
36 # everything else is fine, but we need to recognise when they're pushing
37 # tags, so that the refex expr will have the correct info
38 RW+ refs/tags/ = u1 u2
39 RW+ = u1 u2
41 # can push files in "foo/" only to a tag
42 RW+ VREF/NAME/foo/ = u1 u2
44 RW+ VREF/NAME/foo/ and refs/tags/ = u1 u2
45 - VREF/NAME/foo/ and not refs/tags/ = u1 u2
47 EOF
48 gitolite setup
49 say2 done
51 # ----------------------------------------------------------------------
53 # make sure u3 is not constrained in any way
55 git clone u3:r9 refex-test.repo
56 cd refex-test.repo
58 tsh 'tc u3-f1'
59 git pom
61 mkdir bar foo
62 tsh 'tc bar/thr'
63 git pom
64 git tag v3
65 git push origin v3
66 tsh 'tc foo/rht'
67 git pom
68 git tag 3v
69 git push origin 3v
71 say2 u3 no limits
73 # now test u1's constraints
75 cd ..
76 rm -rf refex-test.repo
78 rm -rf ~/repositories/r9.git
79 gitolite setup
81 git clone u1:r9 refex-test.repo
82 cd refex-test.repo
84 tsh 'tc u1-f1'
85 # cant push master
86 git pom && die 1
87 # can push other branches
88 git push origin master:m1
89 say2 master fail m1 pass
91 mkdir bar foo
92 tsh 'tc bar/one'
93 git push origin master:m1
94 git tag v1
95 # cant push v-tag
96 git push origin v1 && die 2
97 say2 v-tag fail
99 # cant push foo/ to a branch
100 tsh 'tc foo/eno'
101 git push origin master:m1 && die 3
102 say2 foo/ m1 fail
104 # but can push to a non-v-tag
105 git tag 1v
106 git push origin 1v
107 say2 foo/ non-v-tag pass