Applies to: VisualSVN Server 3.9 and later
VisualSVN Server includes a pre-commit hook that allows putting certain restrictions on the log messages for the new commits. Typically, you might want to prohibit empty or short log messages, or log messages without certain text (e.g., without an issue number or ID).
Follow these steps to enable the pre-commit hook:
- Start the VisualSVN Server Manager console.
- Expand the Repositories node.
- Right-click the repository and click Properties.
- Click the Hooks tab.
- Double-click the Pre-commit hook.
- Enter the following commands replacing the parameters with valid values.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^ check-logmessage "%1" -t "%2" ^ --min-size <min-size> IF ERRORLEVEL 1 exit /b 1
TipYou can find the script examples below. - Click OK and Apply.
The check-logmessage command accepts the following options:
Option | Meaning |
-t [--transaction] ARG | Specifies the transaction ID |
--min-size ARG | Minimum allowed number of characters in the commit log message |
--regexp ARG | Regular expression to validate a message. The option is available starting with VisualSVN Server 5.2. |
--filter ARG | Include changes only in specified paths. The option is available starting with VisualSVN Server 5.2. |
Examples
Below you can find examples of scripts that you can use in your repositories.
Reject commits with less than 10 characters in the log message
Use the following pre-commit hook to reject commits with less than 10 characters in the log message:
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^ check-logmessage "%1" -t "%2" ^ --min-size 10 IF ERRORLEVEL 1 exit /b 1
Reject commits without an issue ID in the log message
Use the following pre-commit hook to require an issue number in the commit
log message. The hook validates the log message against the regular
expression ISSUE-\d+
and rejects the commit with a custom
error message when the issue number is missing.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" check-logmessage ^ --regexp "ISSUE-\d+" ^ -t "%2" "%1" IF ERRORLEVEL 1 echo Issue number must be specified. >&2 & exit /b 1
Reject commits into '/project' without an issue ID in the log message
Use the following pre-commit hook to require an issue number in log messages
of commits into the /project
subtree of the repository. The
hook validates the log message against the regular expression
ISSUE-\d+
, but only for commits into /project
in
the repository.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" check-logmessage ^ --regexp "ISSUE-\d+" ^ --filter /project ^ -t "%2" "%1" IF ERRORLEVEL 1 exit /b 1