How can I debug a Subversion script prefix hook?

This seems to be a very simple question, but I'm knocked out. How to test those scripts that were written for the purpose of connection.

As we know, the script runs in the background, and only the error is returned to the SVN console. I tried with a breakpoint, but I can not provide anything for the input of the script.

Does anyone know about this. I write svn hook script on windows, so many hook scripts already written either do not work or do not give the desired result, for example, check the mime type and eol script from apache.

+4
source share
1 answer

I can give you some tips:

  • You need to print to STDERR. This is the only way your script will report errors to you. You can use this for actual testing.
  • I wrote a pre-commit script to take the -t or -r command line option. When pre-committing as a hook, I can use the -t option to pass the transaction number. When starting from the command line, I can use the -r option and give it the version number to run.
  • I also wrote a debug function that allowed me to print out information when I set the -debug command-line -debug . I could turn it on and off.
  • If you are actually checking your hook, use a copy of the repository and make sure that the pre-commit shell script exits with exit code 2 . You will never commit transactions, but you will receive messages in your pre-commit script what happens (that is, if you print everything in STDERR).

You can look at the hook scripts that I am developing to get some ideas. I am using the Data::Dumper Perl module, which can help print data structures in my script.

+5
source

Source: https://habr.com/ru/post/1383516/


All Articles