如何在 windows 上运行的 Visualsvn 服务器预提交钩子中调用 python 脚本 [英] How to call a python script in visualsvn server precommit hook running on windows

查看:30
本文介绍了如何在 windows 上运行的 Visualsvn 服务器预提交钩子中调用 python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 pre-commit hook 实现了一个 python 脚本,以检测提交消息、作者、更改的路径,然后在特定情况下抛出异常或错误.

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.

我想在VisualSVN服务器Pre-commit Hook中设置这个脚本pre-commit.py在 Hooks 中使用这个命令

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

当我想提交时,我收到了这个错误 Access Denied 看起来 pre-commit hook 无法识别我的语法

When I want to commit I got this error Access Denied looks like pre-commit hook doesn't recognize my syntax

推荐答案

Python 脚本不被视为 Windows 上的可执行文件.您应该将它们包装在 Windows Batch 中.例如,预提交钩子脚本可以如下所示:

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%

此 Windows 批处理脚本将运行位于 C:\Repositories\MyRepository\hooks\post-commit.py 的 Python 脚本,并将传递 %1%2 参数.

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.

手动或通过 VisualSVN 服务器管理器控制台将此代码放入存储库的 \hooks\pre-commit.bat\hooks\pre-commit.cmd 文件中:

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. 启动 VisualSVN 服务器管理器控制台.
  2. 右键单击代码库,然后单击属性.
  3. 点击挂钩标签.
  4. 点击预提交挂钩,然后点击编辑.
  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.

这篇关于如何在 windows 上运行的 Visualsvn 服务器预提交钩子中调用 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆