Applies to: VisualSVN Server 5.0 and later
VisualSVN Server includes the check-pathnames
pre-commit hook
for validating file and folder names in incoming transactions. The hook
validates file names in commits and can perform the following checks:
-
Reject files with certain extensions (e.g.,
*.iso
,*.dll
,*.exe
, etc.). - Reject files and folders whose names differ only by case to prevent case-only name conflicts.
- Reject files and folders with names incompatible with the Windows file naming conventions.
Follow these steps to configure the pre-commit hook:
- Start the VisualSVN Server Manager console.
- Expand the Repositories node.
- Right-click a repository and click Properties.
- Click the Hooks tab.
- Double-click the Pre-commit hook.
-
Enter the following commands replacing the placeholder parameters
with valid values.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" check-pathnames ^ --prohibited-name <prohibited-name> ^ -t "%2" "%1" IF ERRORLEVEL 1 exit /b 1
TipYou can find the script examples below. -
Click OK and Apply.
NoteRemember to use
IF ERRORLEVEL 1 exit /b 1
or a similar condition after callingVisualSVNServerHooks.exe
in the hook script. Otherwise, the results of the check will be silently ignored.
Options
The check-pathnames
command accepts the following options:
Option | Meaning |
-t [--transaction] ARG | Specifies the transaction ID. |
--case-conflicts | Checks for absence of case conflicts. |
--prohibited-name ARG | Checks that file and folder names do not match the prohibited pattern. |
--windows-compatible | Checks for compliance with the Windows file naming conventions. |
Examples
Below you can find examples of the scripts that you can use in your repositories.
Rejecting files with the .exe extension
Use the following pre-commit hook to reject commits that add files with
the *.exe
extension.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" check-pathnames ^ --prohibited-name *.exe ^ -t "%2" "%1" IF ERRORLEVEL 1 exit /b 1
Performing all three validation checks in a single command
Use the following pre-commit hook to reject commits that add files with
the *.exe
extension, or with case conflicts, or with names
incompatible with Windows.
"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" check-pathnames ^ --prohibited-name *.exe ^ --case-conflicts ^ --windows-compatible ^ -t "%2" "%1" IF ERRORLEVEL 1 exit /b 1
See also
KB140: Validating commit log messages in VisualSVN Server
KB188: Understanding Subversion repository hooks
SVNBook | pre-commit hook