Server gesitueerde hook scripts

A hook script is a program triggered by some repository event, such as the creation of a new revision or the modification of an unversioned property. Each hook is handed enough information to tell what that event is, what target(s) it's operating on, and the username of the person who triggered the event. Depending on the hook's output or return status, the hook program may continue the action, stop it, or suspend it in some way. Please refer to the chapter on Hook Scripts in the Subversion Book for full details about the hooks which are implemented.

Deze hook scripts worden uitgevoerd door de server waarop het archief zich bevind. Met TortoiseSVN is het mogelijk om eigenlijk hook scripts te maken, die lokaal uitgevoerd worden bij bepaalde gebeurtenissen. Lees de paragraaf met de naam “Hook Scripts op de Client” voor meer informatie.

Sample hook scripts can be found in the hooks directory of the repository. These sample scripts are suitable for Unix/Linux servers but need to be modified if your server is Windows based. The hook can be a batch file or an executable. The sample below shows a batch file which might be used to implement a pre-revprop-change hook.

rem Only allow log messages to be changed.
if "%4" == "svn:log" exit 0
echo Property '%4' cannot be changed >&2
exit 1

Note that anything sent to stdout is discarded. If you want a message to appear in the Commit Reject dialog you must send it to stderr. In a batch file this is achieved using >&2.

Dwingende Hooks

If a hook script rejects your commit then its decision is final. But you can build an override mechanism into the script itself using the Magic Word technique. If the script wants to reject the operation it first scans the log message for a special pass phrase, either a fixed phrase or perhaps the filename with a prefix. If it finds the magic word then it allows the commit to proceed. If the phrase is not found then it can block the commit with a message like You didn't say the magic word. :-)

TortoiseSVN homepage