I would like to run some sort of post commit hook script on a VisualSVN server in order to either add a file (or simply edit a file) to the repository which will include the revision number (and other revision information). I know this is possible to achieve using client scripts, but I want to do it on the server. Any thoughts? Is it possible at all?
2 Answers
You can manage server hooks via the VisualSVN Server Manager:
- Start the Server Manager,
- Select the repository,
- Action | All Tasks | Manage Hooks.
In the dialog it tells you that the revision number is the 2'nd argument. With the revision number, you can use svn.exe and svnlook.exe to do a lot of other tasks... any use?
1 Comment
Technically you can use a post-commit hook script to perform the task. However you should understand that you must NOT modify the original transaction itself (i.e. don't try a start- or pre- commit hooks. Commit of the complementary file with revision details must be performed as a separate one.
In order to retrieve additional revision data you can use svnlook.exe in your hook.
See the SVNBook:
While hook scripts can do almost anything, there is one dimension in which hook script authors should show restraint: do not modify a commit transaction using hook scripts. While it might be tempting to use hook scripts to automatically correct errors, shortcomings, or policy violations present in the files being committed, doing so can cause problems. Subversion keeps client-side caches of certain bits of repository data, and if you change a commit transaction in this way, those caches become indetectably stale. This inconsistency can lead to surprising and unexpected behavior. Instead of modifying the transaction, you should simply validate the transaction in the pre-commit hook and reject the commit if it does not meet the desired requirements. As a bonus, your users will learn the value of careful, compliance-minded work habits.