没有叫Gitblit blockpush挂钩

时间:2015-12-14 13:59:58

标签: git gitblit

我刚刚在gitblit安装的grovy文件夹中编辑了blockpush.groovy scipt。我只是"返回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

我做错了什么?我正在提交并随后推动

enter image description here

我没注意这段代码是重要的部分

 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
        }
    }

1 个答案:

答案 0 :(得分:0)

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