2

gitblit インストールの groovy フォルダーにある blockpush.groovy スクリプトを編集しました。私は単に「false を返す」だけです。スクリプトが呼び出されるかどうかを確認するために。また、テストスクリプトでは、ログファイルには何も書かれていません

Indicate we have started the script
logger.info("blockpush hook triggered by ${user.username} for ${repository.name}: checking ${commands.size} commands")

/*
 * Example rejection of pushes to the master branch of example.git
 */

def file1 = new File('C:\\workspace\\test.txt')
file1.write 'Working with files the Groovy way is easy.\n'

return false

私は何を間違っていますか?私はコミットし、その後プッシュしています

ここに画像の説明を入力

このコードが重要な部分であることに注意を払っていませんでした

 for (ReceiveCommand command : commands) {
        def updatedRef = command.refName
        if (updatedRef.equals('refs/heads/master')) {
            // to reject a command set it's result to anything other than Result.NOT_ATTEMPTED
            command.setResult(Result.REJECTED_OTHER_REASON, "You are not permitted to write to ${repository.name}:${updatedRef}")
            blocked = true
        }
    }
4

1 に答える 1

0

blockpush フック スクリプトを使用するには、リポジトリを構成する必要があります。

于 2015-12-14T14:32:36.337 に答える