fixed up several broken URLs (minor but annoying)
[gitolite.git] / contrib / utils / gitolite-local
blob903b868e87cd43ee198c0f8165c2a903147534d3
1 #!/bin/bash
3 # ----------------------------------------------------------------------
4 # change these lines to suit
5 testconf=$HOME/GITOLITE-TESTCONF
6 gitolite_url=https://github.com/sitaramc/gitolite
7 # change it to something local for frequent use
8 # gitolite_url=file:///tmp/gitolite.git
10 # ----------------------------------------------------------------------
11 # Usage: gitolite-local <options>
13 # Test your gitolite.conf rule lists on your LOCAL machine (without even
14 # pushing to the server!)
16 # (one-time)
18 # 1. put this code somewhere in your $PATH if you wish
19 # 2. edit the line near the top of the script if you want to use some other
20 # directory than the default, for "testconf".
21 # 2. prepare the "testconf" directory by running:
22 # gitolite-local prep
24 # (lather, rinse, repeat)
26 # 1. edit the conf (see notes below for more)
27 # gitolite-local edit
28 # 2. compile the conf
29 # gitolite-local compile
30 # 3. check permissions using "info" command:
31 # gitolite-local info USERNAME
32 # 4. check permissions using "access" command:
33 # gitolite-local access <options for gitolite access command>
34 # 5. clone, fetch, and push if you like!
35 # gitolite-local clone <username> <reponame> <other options for clone>
36 # gitolite-local fetch <username> <options for fetch>
37 # gitolite-local push <username> <options for push>
39 # note on editing the conf: you don't have to use the edit command; you can
40 # also directly edit '.gitolite/conf/gitolite.conf' in the 'testconf'
41 # directory. You'll need to do that if your gitolite conf consists of more
42 # than just one file (like if you have includes, etc.)
44 # note on the clone command: most of the options won't work for clone, unless
45 # git is ok with them being placed *after* the repo name.
47 # ----------------------------------------------------------------------
48 die() { echo "$@" >&2; exit 1; }
49 usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
50 [ -z "$1" ] && usage
52 # ----------------------------------------------------------------------
53 if [ $1 == prep ]
54 then
55 set -e
57 [ -d $testconf ] && die "directory '$testconf' already exists"
59 mkdir $testconf
60 cd $testconf
62 export HOME=$PWD
64 echo getting gitolite source...
65 git clone $gitolite_url gitolite
66 echo
68 echo installing gitolite...
69 gitolite/install >/dev/null
70 echo
72 echo setting up gitolite...
73 export PATH=$PWD/gitolite/src:$PATH
74 gitolite setup -a admin
75 echo
77 exit 0
80 od=$PWD
81 cd $testconf
82 export HOME=$PWD
83 export PATH=$PWD/gitolite/src:$PATH
85 if [ $1 = edit ]
86 then
87 editor=${EDITOR:-vim}
88 $editor .gitolite/conf/gitolite.conf
89 elif [ $1 = compile ]
90 then
91 gitolite compile
92 elif [ $1 = compile+ ]
93 then
94 gitolite compile\; gitolite trigger POST_COMPILE
95 elif [ $1 = info ]
96 then
97 shift
98 user=$1
99 shift
101 GL_USER=$user gitolite info "$@"
102 elif [ $1 = access ]
103 then
104 shift
106 gitolite access "$@"
107 elif [ $1 = clone ]
108 then
109 shift
110 export G3T_USER=$1
111 shift
113 cd $od
114 export GL_BINDIR=$HOME/gitolite/t
115 # or you could do it the long way, using 'gitolite query-rc GL_BINDIR'
116 repo=$1; shift
117 git clone --upload-pack=$GL_BINDIR/gitolite-upload-pack file:///$repo "$@"
118 elif [ $1 = fetch ]
119 then
120 shift
121 export G3T_USER=$1
122 shift
124 cd $od
125 export GL_BINDIR=$HOME/gitolite/t
126 git fetch --upload-pack=$GL_BINDIR/gitolite-upload-pack "$@"
127 elif [ $1 = push ]
128 then
129 shift
130 export G3T_USER=$1
131 shift
133 cd $od
134 export GL_BINDIR=$HOME/gitolite/t
135 git push --receive-pack=$GL_BINDIR/gitolite-receive-pack "$@"