UserModel user = new UserModel("mock");
String gitblitUrl = GitBlitSuite.url;
File groovyDir = repositories().getHooksFolder();
GroovyScriptEngine gse = new GroovyScriptEngine(groovyDir.getAbsolutePath());
Binding binding = new Binding();
binding.setVariable("gitblit", gitblit);
binding.setVariable("repository", repository);
binding.setVariable("user", user);
binding.setVariable("commands", commands);
binding.setVariable("url", gitblitUrl);
binding.setVariable("logger", logger);
binding.setVariable("clientLogger", clientLogger);
Object result = gse.run(script, binding);
if (result instanceof Boolean) {
if (!((Boolean) result)) {
throw new GitBlitException(MessageFormat.format(
"Groovy script {0} has failed! Hook scripts aborted.", script));
}