不能不SVN $ P $与Windows服务器对提交脚本 [英] Can't fail SVN pre-commit script with Windows server
问题描述
我真的写一个SVN pre-commit.bat文件,该文件调用一个Python脚本来查询我们的问题跟踪系统,以确定用户提供的问题跟踪ID是正确的状态(如开放状态),并与合适的项目有关。 SVN的服务器运行的是Windows(2003服务器,我认为 - 我可以用我们的IT部门检查,如果它的问题...)。
I`m writing an SVN pre-commit.bat file which calls a Python script to query our issue tracking system to determine of the user-supplied issue tracking ID is in the correct state (e.g. "open" state) and associated with the right project. The SVN server is running Windows (2003 server I think - I can check with our IT group if it matters...).
问题是,我似乎无法让SVN提交失败*;它总是成功。 AFAIK Python脚本是做什么它应该;它所谓的sys.exit(1)为失败(与sys.exit(0)成功)。对于.bat文件我已经适应了在这个论坛上,据说工作的一些例子,并作为然而,没有运气。这里是略为简化.bat文件,
The issue is that I can't seem to make the SVN commit fail*; it always succeeds. AFAIK the Python script is doing what it should; it calls "sys.exit(1)" for failures (and "sys.exit(0)" for success). For the .bat file I have adapted some examples in this forum which are said to work and as of yet, no luck. Here's the slightly simplified .bat file,
@echo off
set repos=%1
set transaction=%2
set proj=ferry
\Python26\python svn_sync.py -s --repos=%repos% --transaction=%transaction% --project=%proj%
IF %ERRORLEVEL% GTR 0 (GOTO err) else exit 0
REM This should return a failure to Subversion, but does not
:err
echo 1>&2
echo Your commit has failed due to invalid PR or PR state. 1>&2
echo Thanks 1>&2
exit 1
我又知道脚本运行(即不是一个环境变量的问题在服务器上),而 sys.exit(1)
code是被击中。此外我真的很确定的'犯错'功能越来越来看,这仅仅是退出1返回code是越来越被忽略SVN?
Again I know that the script is being run (i.e. not a env variable issue on the server), and the sys.exit(1)
code is being hit. Also I`m quite sure the 'err' function getting run, it is simply that the "exit 1" return code is getting ignored by SVN?
*注意:并不完全正确;我曾经做了一个承诺的唯一方法失败是当Python脚本有一个运行时错误。产生故意运行时错误,但是,是不是一个可以接受的解决方法在这种情况下。
*Note: Not quite true; the only way I have ever made a commit fail is when the Python script has a run-time error. Generating an intentional run-time error, however, is not an acceptable work-around in this case.
感谢您的关注。
推荐答案
试着改变退出1
到退出/ B 1
。 退出
将退出命令间preTER(CMD.EXE); 退出/ B
将退出当前批处理脚本而不是命令间preTER。
Try changing exit 1
to exit /b 1
. exit
will quit the command interpreter (cmd.exe); exit /b
will quit the current batch script but not the command interpreter.
退出1
可关闭该命令除preTER其中pre-commit脚本运行,所以退出code ISN ŧ提供给SVN,如果它也同样的命令间preTER下运行。
exit 1
may be closing the command interpreter in which the pre-commit script is running, so the exit code isn't available to SVN if it's also running under the same command interpreter.
这篇关于不能不SVN $ P $与Windows服务器对提交脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!