3 % "wild" repos (user created repos)
7 The wildrepos feature allows you to specify access control rules using regular
8 expression patterns, so you can have many actual repos being served by a
9 single set of rules in the config file. The [regex][] can also include the
10 word `CREATOR` in it, allowing you to parametrise the name of the user
15 If you're curious about the feature but you aren't sure if you want to read
16 the whole page, here's a very simple example.
20 ![](images/wild-1.png "Figure 1")
24 This is what the admin added to the conf file.
26 User 'u1' then runs `git clone git@host:foo/u1/bar`, creating the repo.
27 Notice the repo name matches the regex, if you substitute the user's name
34 ![](images/wild-2.png "Figure 2")
38 This is the effective rule list for 'foo/u1/bar' immediately after the user
39 creates it. The parts that are not dimmed out can be changed by the creator
40 (user 'u1') using the [perms][] command to add 'u2' as a writer and 'u3' and
47 ![](images/wild-3.png "Figure 3")
51 This is the effective rule list that applies to the repo.
53 Note that both these "effective rule lists" were created without touching the
54 actual conf file or any admin intervention.
58 And that's it for our quick intro example. The rest of this page will explain
59 all this in much more detail.
61 # declaring wild repos in the conf file
65 Here's a slightly more detailed example, starting with what the admin puts in
68 Note the "C" permission. This is a standalone "C", which gives the named
69 users the right to *create a repo*. @@gray(This is not to be confused with
70 the "RWC" permission or its variants described [elsewhere][write-types], which
71 are about creating *branches*, not *repos*.)@@
81 repo assignments/CREATOR/a[0-9][0-9]
91 # (**user**) creating a specific repo {#create}
93 For now, ignore the special usernames READERS and WRITERS, and just create a
94 new repo, as user "u4" (a student):
96 $ git clone git@server:assignments/u4/a12
97 Initialized empty Git repository in /home/git/repositories/assignments/u4/a12.git/
98 warning: You appear to have cloned an empty repository.
100 # a slightly different example
104 Here's how the same example would look if you did not want the CREATOR's name
105 to be part of the actual repo name.
110 repo assignments/a[0-9][0-9]
119 We haven't changed anything except the repo name regex. This means that the
120 first student that creates, say, `assignments/a12` becomes the owner.
121 Mistakes (such as claiming a12 instead of a13) need to be rectified by an
122 admin logging on to the back end, though it's not too difficult.
124 You could also repace the C line like this:
128 and have a TA create the repos in advance.
130 # repo regex patterns
132 ## regex pattern versus normal repo
134 Due to projects like `gtk+`, the `+` character is now considered a valid
135 character for an *ordinary* repo. Therefore, a regex like `foo/.+` does not
136 look like a [regex][] to gitolite. Use `foo/..*` if you want that.
138 Also, `..*` by itself is not considered a valid repo regex. Try
139 `[a-zA-Z0-9].*`. `CREATOR/..*` will also work.
141 ## line-anchored regexes
145 repo assignments/S[0-9]+/A[0-9]+
147 would match `assignments/S02/A37`. It will not match `assignments/S02/ABC`,
148 or `assignments/S02/a37`, obviously.
150 But you may be surprised to find that it does not match even
151 `assignments/S02/A37/B99`. This is because internally, gitolite
152 *line-anchors* the given regex; so that regex actually becomes
153 `^assignments/S[0-9]+/A[0-9]+$` -- notice the line beginning and ending
158 > *Side-note: contrast with refexes*
160 > Just for interest, note that this is in contrast to the [refexes][refex]
161 > for the normal "branch" permissions. Refexes are only anchored at the
162 > start; a regex like `refs/heads/master` actually can match
163 > `refs/heads/master01/bar` as well, even if no one will actually push such
164 > a branch! You can anchor both sides if you really care, by using
165 > `master$` instead of `master`, but that is *not* the default for refexes.
171 The words READERS and WRITERS are called "role" names. The access rules in
172 the conf file decide what permissions these roles have, but they don't say
173 what users are in each of these roles.
175 That needs to be done by the creator of the repo, using the `perms` command.
176 You can run `ssh git@host perms -h` for detailed help, but in brief, that
177 command lets you give and take away roles to users. [This][perms] has some
180 ## adding other roles
186 If you want to have more than just the 2 default roles, say something like:
188 You can add the new names to the ROLES hash in the [rc file][rc]; see comments
189 in that file for how to do that. Be sure to run the 2 commands mentioned
190 there after you have added the roles.
197 RW refs/tags/ = TESTERS
207 ### <font color="red">**IMPORTANT WARNING ABOUT THIS FEATURE**</font> {#rolenamewarn}
209 Please make sure that none of the role names conflict with any of the user
210 names or group names in the system. For example, if you have a user called
211 "foo" or a group called "@foo", make sure you do not include "foo" as a valid
212 role in the ROLES hash.
214 You can keep things sane by using UPPERCASE names for roles, while keeping all
215 your user and group names lowercase; then you don't have to worry about this
218 ## setting default roles
220 You can setup some default role assignments as soon as a new wild repo is
225 * Enable the 'set-default-roles' feature in the rc file by uncommenting it
226 if it is already present or adding it to the ENABLE list if it is not.
228 * Supply a set of default role assignments for a wild repo regex by adding
229 lines like this to the repo config para:
231 option default.roles-1 = READERS @all
232 option default.roles-2 = WRITERS @senior-devs
234 This will then behave as if the [perms][] command was used immediately after
235 the repo was created to add those two role assignments.
237 If you want to simulate the old (pre v3.5) `DEFAULT_ROLE_PERMS` rc file
238 variable, just add them under a `repo @all` line. (Remember that this only
239 affects newly created wild repos, despite the '@all' name).
243 See the section on `OWNER_ROLENAME` in the [rc file page][rc].
247 In order to see what repositories were created from a wildcard, use the 'info'
248 command. Try `ssh git@host info -h` to get help on the info command.
250 # deleting a wild repo
252 Run the whimsically named "D" command -- try `ssh git@host D -h` for more info
253 on how to delete a wild repo. (Yes the command is "D"; it's meant to be a
254 counterpart to the "C" permission that allowed you to create the repo in the
255 first place). Of course this only works if your admin has enabled the command
256 (gitolite ships with the command disabled for remote use).
258 # appendix 1: owner and creator
260 A wild repo is created by one specific user. This user is usually called the
261 **creator** of the repo: his username is placed in a file called gl-creator in
262 the (bare) repo directory, any permissions given in the gitolite.conf file to
263 "CREATOR" will be applicable to this user, he is the only person who can give
264 permissions to other users (by running the 'perms' command), etc.
266 But, as I said in [this mail](https://groups.google.com/d/msg/gitolite/nFbnQuO0ztM/tXiVs5ah2bcJ):
268 Until about a year ago, Gitolite only knew the concept of a "creator", and
271 But then people started seeing the need for more than one "owner", because
272 wild repos may be *created* by one person, but they often needed to be
273 *administered* by one of several people.
275 So now, even though large parts of the documentation probably conflate
276 "creator" and "owner", you can see wild.html ([wild]) and rc.html ([rc])
277 to actually understand how this larger group become the "owner".