2012-03-16 02:54:47 +01:00
|
|
|
# customising gitolite
|
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
Much of gitolite (g3)'s functionality comes from programs and scripts that are
|
|
|
|
not considered "core". This keeps the core simpler, and allows you to enhance
|
2012-04-05 18:01:23 +02:00
|
|
|
gitolite for your own purposes without too much fuss. (As an extreme example,
|
|
|
|
even mirroring is not in core now!)
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
This document will tell you about the types of non-core programs, and
|
|
|
|
how/where to install your own. (Actually *writing* the code is described in
|
|
|
|
the [developer notes][dev-notes] page).
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-04-06 10:07:30 +02:00
|
|
|
----
|
|
|
|
|
|
|
|
[[TOC]]
|
|
|
|
|
|
|
|
----
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
## introduction
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
There are 5 basic types of non-core programs.
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-04-17 03:13:13 +02:00
|
|
|
* *Commands* can be run from the shell command line. Among those, the ones
|
2012-04-05 18:01:23 +02:00
|
|
|
listed in the COMMANDS hash of the rc file can also be run remotely.
|
2012-06-13 11:13:19 +02:00
|
|
|
* *Hooks* are standard git hooks.
|
2012-04-17 03:13:13 +02:00
|
|
|
* *Sugar scripts* change the conf language for your convenience. The word
|
2012-04-05 18:01:23 +02:00
|
|
|
sugar comes from "syntactic sugar".
|
2012-04-17 03:13:13 +02:00
|
|
|
* *Triggers* are to gitolite what hooks are to git. I just chose a
|
2012-03-26 08:23:00 +02:00
|
|
|
different name to avoid confusion and constant disambiguation in the docs.
|
|
|
|
* **VREFs** are extensions to the access control check part of gitolite.
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 18:00:12 +02:00
|
|
|
[Here][non-core] is a list of non-core programs shipped with gitolite, with
|
|
|
|
some description of each.
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
## locations
|
|
|
|
|
|
|
|
### default/primary location of non-core programs
|
|
|
|
|
|
|
|
Regardless of how you installed gitolite, `gitolite query-rc GL_BINDIR` will
|
|
|
|
tell you where the programs reside. Within that directory, the locations of
|
|
|
|
non-core programs are:
|
|
|
|
|
|
|
|
* `commands` for commands.
|
|
|
|
* `syntactic-sugar` for sugar scripts.
|
|
|
|
* `triggers` and `lib/Gitolite/Triggers` for triggers ([this][triggers] will
|
|
|
|
explain the difference).
|
|
|
|
* `VREF` for [VREFs][vref].
|
|
|
|
|
|
|
|
### #localcode alternate location -- the `LOCAL_CODE` rc variable
|
|
|
|
|
|
|
|
If you want to add new non-core programs to your installation, or override the
|
|
|
|
shipped non-core programs with your own versions, it's easy enough to simply
|
|
|
|
copy your programs to the appropriate directory above, but then they'd get
|
|
|
|
wiped out on the next upgrade.
|
|
|
|
|
|
|
|
A simple, "git-ish", method is to maintain a "local" branch in your clone of
|
|
|
|
the gitolite source repo and make your changes there. Maintain them using
|
|
|
|
rebase or merge when you 'git pull' gitolite itself, then use the rebased or
|
|
|
|
merged "local" as the source for your gitolite upgrades. Works very nicely,
|
|
|
|
and uses nothing but your git knowledge.
|
|
|
|
|
|
|
|
Sadly, it doesn't work for people installing from RPMs/DEBs; their "primary
|
|
|
|
location" has already been setup, so any site-local customisations have to be
|
|
|
|
done elsewhere.
|
|
|
|
|
|
|
|
This is where `LOCAL_CODE` comes in. If you define the `LOCAL_CODE` rc
|
|
|
|
variable, then its value (**please use a FULL path**) describes a location
|
|
|
|
where you can have any or all of these subdirectories:
|
|
|
|
|
|
|
|
* `commands`
|
|
|
|
* `hooks/common`
|
|
|
|
* `syntactic-sugar`
|
|
|
|
* `triggers` and `lib/Gitolite/Triggers`
|
|
|
|
* `VREF`
|
|
|
|
|
|
|
|
You might have noticed there's a new `hooks/common` directory here so you can
|
|
|
|
add hooks also using this mechanism. Unlike the rest of the directories,
|
|
|
|
adding new hooks to `hooks/common` requires that you follow up with `gitolite
|
|
|
|
setup`, or at least `gitolite setup --hooks-only`.
|
|
|
|
|
|
|
|
### #pushcode managing custom code via the gitolite-admin repo
|
|
|
|
|
|
|
|
The location given in `LOCAL_CODE` could be anywhere on disk.
|
|
|
|
|
|
|
|
However, if you point it to someplace inside `$GL_ADMIN_BASE` (i.e.,
|
|
|
|
`$HOME/.gitolite`), then you can version those programs using the
|
|
|
|
gitolite-admin repo.
|
|
|
|
|
|
|
|
I suggest using a directory called "local-code" within the gitolite-admin repo
|
|
|
|
that contains as much of the above directory structure you need. If you do
|
|
|
|
that, then this is what you'd have in the rc file:
|
|
|
|
|
|
|
|
LOCAL_CODE => "$ENV{HOME}/.gitolite/local-code",
|
|
|
|
|
|
|
|
When you do this, gitolite takes care of everything automatically, including
|
|
|
|
running `gitolite setup --hooks-only` when you change any hooks and push.
|
|
|
|
**However, if you do this, anyone who can push changes to the admin repo will
|
|
|
|
effectively be able to run any arbitrary command on the server.**
|
|
|
|
|
|
|
|
## types of non-core programs
|
|
|
|
|
|
|
|
### #commands gitolite "commands"
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
Gitolite comes with several commands that users can run. Remote users run
|
2012-03-26 08:23:00 +02:00
|
|
|
commands by saying:
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
ssh git@host command-name [args...]
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
while on the server you can run
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
gitolite command [args...]
|
2012-03-16 02:54:47 +01:00
|
|
|
|
2012-03-26 08:23:00 +02:00
|
|
|
Very few commands are designed to be run both ways, but it can be done, by
|
|
|
|
checking for the presence of env var `GL_USER`.
|
|
|
|
|
|
|
|
You can get a **list of available commands** by using the `help` command.
|
|
|
|
Naturally, a remote user will see a much smaller list than the server user.
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
You allow a command to be run from remote clients by adding its name to (or
|
|
|
|
uncommenting it if it's already added but commented out) the COMMANDS hash in
|
|
|
|
the [rc][] file.
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
### #hooks hooks and gitolite
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
You can install any hooks except these:
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
* (all repos) gitolite reserves the `update` hook. See the "update hook"
|
|
|
|
section in [dev-notes][] if you want additional update hook functionality.
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
* (gitolite-admin repo only) gitolite reserves the `post-update` hook.
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
How/where to install them is described in detail in the "locations" section
|
|
|
|
above, especially [this][localcode] and [this][pushcode]. The summary is that
|
|
|
|
you put them in the "hooks/common" sub-directory within the directory whose
|
|
|
|
name is given in the `LOCAL_CODE` rc variable.
|
2012-03-26 08:23:00 +02:00
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
### #sugar syntactic sugar
|
2012-03-26 08:23:00 +02:00
|
|
|
|
|
|
|
Sugar scripts help you change the perceived syntax of the conf language. The
|
2012-04-05 18:01:23 +02:00
|
|
|
base syntax of the language is very simple, so sugar scripts take something
|
|
|
|
*else* and convert it into that.
|
2012-03-26 08:23:00 +02:00
|
|
|
|
|
|
|
That way, the admin sees additional features (like allowing continuation
|
|
|
|
lines), while the parser in the core gitolite engine does not change.
|
|
|
|
|
|
|
|
If you want to write your own sugar scripts, please read the "your own sugar"
|
|
|
|
section in [dev-notes][] first then email me.
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
### triggers
|
2012-03-26 08:23:00 +02:00
|
|
|
|
|
|
|
Triggers have their own [document][triggers].
|
|
|
|
|
2012-06-13 11:13:19 +02:00
|
|
|
### VREFs
|
2012-03-26 08:23:00 +02:00
|
|
|
|
|
|
|
VREFs also have their own [document][vref].
|