How to call a python script in visualsvn server precommit hook running on windows

独自空忆成欢 提交于 2019-12-11 00:42:43

问题


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:

  1. Start the VisualSVN Server Manager console.
  2. Right-click a repository and click Properties.
  3. Click the Hooks tab.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!