提交到存储库时出现以下错误:
post-commit hook failed (exit code 255) with no output.
提交后代码如下:
@echo off
setlocal enableextensions
set REPOS=%1
set REV=%2
set TEMPFILE=C:\TEMP\%REV%.txt
set LOGFILE=D:\svn\logs\mysite\post_commit.log
set MANTIS_PATH="D:\home\mantis"
"C:\Program Files\SlikSvn\bin\svnlook" author %REPOS% -r %REV% >> %TEMPFILE% 2>>C:\TEMP\err.txt
"C:\Program Files\SlikSvn\bin\svnlook" date %REPOS% -r %REV% >> %TEMPFILE% 2>>C:\TEMP\err.txt
"C:\Program Files\SlikSvn\bin\svnlook" changed %REPOS% -r %REV% >> %TEMPFILE% 2>>C:\TEMP\err.txt
echo revision:[%REV%] >> %TEMPFILE% 2>>C:\TEMP\err.txt
"C:\Program Files\SlikSvn\bin\svnlook" log %REPOS% -r %REV% >> %TEMPFILE% 2>>C:\TEMP\err.txt
date /T >> %LOGFILE% 2>>C:\TEMP\err.txt
time /T >> %LOGFILE% 2>>C:\TEMP\err.txt
D:\wamp\bin\php\php5.3.0\php.exe %MANTIS_PATH%\scripts\checkin.php < %TEMPFILE% >> %LOGFILE% 2>>C:\TEMP\err.txt
- 正如你所看到的,有大量的错误日志,但错误日志永远不会被填充(除非我输入了一个明显的错误,比如缺少路径)
- 开发环境和实时环境都是 Windows
- 似乎出现错误的那一行是最后一行——调用 PHP 的地方。当我把它拿出来时,提交工作没有问题
- 当我在命令行上手动运行它时,它可以工作并且不显示任何(明显的)错误。Afaik svn 默认用户在 SYSTEM 下运行,该用户的权限足够高,不必担心
您可能已经知道,这是将我的 SVN 签入与 Mantis 错误跟踪器连接起来。有趣的是,PHP 脚本正在执行,即注释被添加到错误中并且问题的自动关闭正在工作。它似乎只是出于某种原因出错。
我正在使用 TortoiseSVN 提交,但使用命令行 (SlikSVN) 我得到相同的输出:
svn ci -m "this is a test" test.txt
Sending test.txt
Transmitting file data .
Committed revision 1337.
Warning: post-commit hook failed (exit code 255) with no output.
Mantis 的 checkin.php 看起来像这样(为了便于阅读,删除了一些一般性注释):
#!/usr/bin/php -q
<?php
global $g_bypass_headers;
$g_bypass_headers = 1;
require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );
# Make sure this script doesn't run via the webserver
if( php_sapi_name() != 'cli' ) {
echo "checkin.php is not allowed to run through the webserver.\n";
exit( 1 );
}
# Check that the username is set and exists
$t_username = config_get( 'source_control_account' );
if( is_blank( $t_username ) || ( user_get_id_by_name( $t_username ) === false ) ) {
echo "Invalid source control account ('$t_username').\n";
exit( 1 );
}
if( !defined( "STDIN" ) ) {
define( "STDIN", fopen( 'php://stdin', 'r' ) );
}
# Detect references to issues + concat all lines to have the comment log.
$t_commit_regexp = config_get( 'source_control_regexp' );
$t_commit_fixed_regexp = config_get( 'source_control_fixed_regexp' );
$t_comment = '';
$t_issues = array();
$t_fixed_issues = array();
while(( $t_line = fgets( STDIN, 1024 ) ) ) {
$t_comment .= $t_line;
if( preg_match_all( $t_commit_regexp, $t_line, $t_matches ) ) {
$t_count = count( $t_matches[0] );
for( $i = 0;$i < $t_count;++$i ) {
$t_issues[] = $t_matches[1][$i];
}
}
if( preg_match_all( $t_commit_fixed_regexp, $t_line, $t_matches ) ) {
$t_count = count( $t_matches[0] );
for( $i = 0;$i < $t_count;++$i ) {
$t_fixed_issues[] = $t_matches[1][$i];
}
}
}
# If no issues found, then no work to do.
if(( count( $t_issues ) == 0 ) && ( count( $t_fixed_issues ) == 0 ) ) {
echo "Comment does not reference any issues.\n";
exit( 0 );
}
# Login as source control user
if( !auth_attempt_script_login( $t_username ) ) {
echo "Unable to login\n";
exit( 1 );
}
# history parameters are reserved for future use.
$t_history_old_value = '';
$t_history_new_value = '';
# add note to each bug only once
$t_issues = array_unique( $t_issues );
$t_fixed_issues = array_unique( $t_fixed_issues );
# Call the custom function to register the checkin on each issue.
foreach( $t_issues as $t_issue_id ) {
if( !in_array( $t_issue_id, $t_fixed_issues ) ) {
helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment, $t_history_old_value, $t_history_new_value, false ) );
}
}
foreach( $t_fixed_issues as $t_issue_id ) {
helper_call_custom_function( 'checkin', array( $t_issue_id, $t_comment, $t_history_old_value, $t_history_new_value, true ) );
}
exit( 0 );