未调用 Gitblit blockpush 钩子

Gitblit blockpush hook not called

我刚刚编辑了gitblit安装的groovy文件夹中的blockpush.groovy脚本。我只是 "return 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
        }
    }

您需要配置存储库以使用 blockpush 挂钩脚本。