2

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 2

4

You can manage server hooks via the VisualSVN Server Manager:

  1. Start the Server Manager,
  2. Select the repository,
  3. 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?

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for answer, but I don't see the manage hooks task. I'll need to upgrade to the latest version I guess. I'll upgrade and check it out.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.