No announcement yet.

Server Side Pre-Commit hook to check for illegal characters

  • Filter
  • Time
  • Show
Clear All
new posts

  • Server Side Pre-Commit hook to check for illegal characters

    Hey guys,

    I'm pretty new to SVN and I'm just starting to understand hooks.
    At my office we've started using SVN in a multi OS environment (Windows and MacOS).

    We use VisualSVN hosted on one of our servers and I'm looking for this server to check for illegal characters that are part of file names.

    Windows does not allow for certain characters such as ?, /, \, | etc, whereas Mac can.
    We've recently had an incident where somebody has unconventionally used a ? in a filename which has corrupted that entire revision no. for Windows users.

    As I said it is very unconventional but I would prefer if we could implement some pre-hook on the server and reject the commit when it detects one of these characters.

    Thanks in advance. I'm open to any suggestions

  • #2
    2 classes of hooks:
    - Pre-hooks are enforcement in that non-zero exit value stops the change from being made.
    - Post-hooks are automation/notification since they happen "after" (and sometimes not at all).

    You need the "pre-commit" hook.

    Create a repository on your client via the command line. Go into the repository to the "hooks" directory. In there you'll find a bunch of examples (e.g. "pre-commit.tmpl"). Looking for specific unhappy characters should be pretty simple.

    On linux the script must be:
    0. located in the repository's "hooks" directory.
    1. properly named (e.g. "pre-commit.tmpl" must be renamed to "pre-commit").
    2. executable (e.g. "chmod 0755 pre-commit").
    3. ownership does not matter unless the script is owned by some random account (or root) and then the permissions must be proper to enable execution by the account(s) that is(are) used to update your repository (e.g. Apache, svnserve, file:///).