From adef42eefc08541f0433147441c2f2d575ac134f Mon Sep 17 00:00:00 2001
From: Lukasz Jader <ljaderdev@gmail.com>
Date: Sat, 14 Jul 2012 08:01:52 -0400
Subject: [PATCH] Add polish variants of welcome.mkd, login.mkd and EmptyRepositoryPage
---
src/com/gitblit/GitServlet.java | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/com/gitblit/GitServlet.java b/src/com/gitblit/GitServlet.java
index 36e1c3e..68097cb 100644
--- a/src/com/gitblit/GitServlet.java
+++ b/src/com/gitblit/GitServlet.java
@@ -50,6 +50,8 @@
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ClientLogger;
+import com.gitblit.utils.FileUtils;
import com.gitblit.utils.HttpUtils;
import com.gitblit.utils.StringUtils;
@@ -77,7 +79,12 @@
public void init(ServletConfig config) throws ServletException {
groovyDir = GitBlit.getGroovyScriptsFolder();
try {
- gse = new GroovyScriptEngine(groovyDir.getAbsolutePath());
+ // set Grape root
+ File grapeRoot = new File(GitBlit.getString(Keys.groovy.grapeFolder, "groovy/grape")).getAbsoluteFile();
+ grapeRoot.mkdirs();
+ System.setProperty("grape.root", grapeRoot.getAbsolutePath());
+
+ gse = new GroovyScriptEngine(groovyDir.getAbsolutePath());
} catch (IOException e) {
throw new ServletException("Failed to instantiate Groovy Script Engine!", e);
}
@@ -99,9 +106,9 @@
}
/**
- * Transitional wrapper class to configure the JGit 1.2 GitFilter.
- * This GitServlet will probably be replaced by a GitFilter so that Gitblit
- * can serve Git repositories on the root URL and not a /git sub-url.
+ * Transitional wrapper class to configure the JGit 1.2 GitFilter. This
+ * GitServlet will probably be replaced by a GitFilter so that Gitblit can
+ * serve Git repositories on the root URL and not a /git sub-url.
*
* @author James Moger
*
@@ -160,12 +167,12 @@
*/
@Override
public void onPreReceive(ReceivePack rp, Collection<ReceiveCommand> commands) {
- Set<String> scripts = new LinkedHashSet<String>();
- scripts.addAll(GitBlit.getStrings(Keys.groovy.preReceiveScripts));
RepositoryModel repository = getRepositoryModel(rp);
+ Set<String> scripts = new LinkedHashSet<String>();
+ scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository));
scripts.addAll(repository.preReceiveScripts);
UserModel user = getUserModel(rp);
- runGroovy(repository, user, commands, scripts);
+ runGroovy(repository, user, commands, rp, scripts);
for (ReceiveCommand cmd : commands) {
if (!Result.NOT_ATTEMPTED.equals(cmd.getResult())) {
logger.warn(MessageFormat.format("{0} {1} because \"{2}\"", cmd.getNewId()
@@ -188,12 +195,12 @@
logger.info("skipping post-receive hooks, no refs created, updated, or removed");
return;
}
- Set<String> scripts = new LinkedHashSet<String>();
- scripts.addAll(GitBlit.getStrings(Keys.groovy.postReceiveScripts));
RepositoryModel repository = getRepositoryModel(rp);
+ Set<String> scripts = new LinkedHashSet<String>();
+ scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository));
scripts.addAll(repository.postReceiveScripts);
UserModel user = getUserModel(rp);
- runGroovy(repository, user, commands, scripts);
+ runGroovy(repository, user, commands, rp, scripts);
// Experimental
// runNativeScript(rp, "hooks/post-receive", commands);
@@ -207,9 +214,7 @@
*/
protected RepositoryModel getRepositoryModel(ReceivePack rp) {
Repository repository = rp.getRepository();
- String rootPath = GitBlit.getRepositoriesFolder().getAbsolutePath();
- String repositoryName = repository.getDirectory().getAbsolutePath();
- repositoryName = repositoryName.substring(rootPath.length() + 1);
+ String repositoryName = FileUtils.getRelativePath(GitBlit.getRepositoriesFolder(), repository.getDirectory());
RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
return model;
}
@@ -239,7 +244,7 @@
* @param scripts
*/
protected void runGroovy(RepositoryModel repository, UserModel user,
- Collection<ReceiveCommand> commands, Set<String> scripts) {
+ Collection<ReceiveCommand> commands, ReceivePack rp, Set<String> scripts) {
if (scripts == null || scripts.size() == 0) {
// no Groovy scripts to execute
return;
@@ -252,6 +257,7 @@
binding.setVariable("commands", commands);
binding.setVariable("url", gitblitUrl);
binding.setVariable("logger", logger);
+ binding.setVariable("clientLogger", new ClientLogger(rp));
for (String script : scripts) {
if (StringUtils.isEmpty(script)) {
continue;
--
Gitblit v1.9.1