このエラーが発生する理由:出力なしでコミット後のフックが失敗しました(コード255を終了)

StackOverflow https://stackoverflow.com/questions/5934972

質問

リポジトリにコミットすると、次のエラーが発生します。

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は、デフォルトのユーザーによってシステムの下で実行されます。

おそらく作成されたように、これはMantis BugトラッカーとSVNチェックインを接続しています。興味深いのは、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 );

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top