问题
I Implement a python script for the pre-commit hook to detect the commit message, author, changed path then throw exception or error in specifics cases.
I want to set this script pre-commit.py in the VisualSVN server Pre-commit Hook using this command in the Hooks
C:\Users\momo\Desktop\pre-commit.py %1 %2
When I want to commit I got this error Access Denied
looks like pre-commit hook doesn't recognize my syntax
回答1:
Python scripts are not considered as executable files on Windows. You should wrap them around in Windows Batch. For example, a pre-commit hook script can look as follows:
set REPOS-PATH=%1
set TXN-NAME=%2
"C:\Python27\python.exe" "C:\Repositories\MyRepository\hooks\pre-commit.py" %REPOS-PATH% %TXN-NAME%
This Windows Batch script will run Python script located at C:\Repositories\MyRepository\hooks\post-commit.py
and will pass the %1
and %2
arguments.
Put this code into your repository's \hooks\pre-commit.bat
or \hooks\pre-commit.cmd
file manually or via the VisualSVN Server Manager console:
- Start the VisualSVN Server Manager console.
- Right-click a repository and click Properties.
- Click the Hooks tab.
- Click the Pre-commit hook and click Edit.
来源:https://stackoverflow.com/questions/54356967/how-to-call-a-python-script-in-visualsvn-server-precommit-hook-running-on-window