From 4c0100402ea53368e7c38bf01051a8ba6b019da8 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 11 Jan 2012 20:07:41 -0500
Subject: [PATCH] Fixed sendmail.groovy branch/tag labeling
---
src/com/gitblit/GitBlit.java | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 89dcbf1..bf3660d 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -75,6 +75,7 @@
import com.gitblit.models.SettingModel;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.FederationUtils;
import com.gitblit.utils.JGitUtils;
@@ -451,7 +452,7 @@
List<String> names = new ArrayList<String>(userService.getAllUsernames());
return names;
}
-
+
/**
* Returns the list of all users available to the login service.
*
@@ -545,7 +546,7 @@
List<String> teams = new ArrayList<String>(userService.getAllTeamNames());
return teams;
}
-
+
/**
* Returns the list of available teams that a user or repository may be
* assigned to.
@@ -652,21 +653,38 @@
* @return repository or null
*/
public Repository getRepository(String repositoryName) {
+ return getRepository(repositoryName, true);
+ }
+
+ /**
+ * Returns the JGit repository for the specified name.
+ *
+ * @param repositoryName
+ * @param logError
+ * @return repository or null
+ */
+ public Repository getRepository(String repositoryName, boolean logError) {
Repository r = null;
try {
r = repositoryResolver.open(null, repositoryName);
} catch (RepositoryNotFoundException e) {
r = null;
- logger.error("GitBlit.getRepository(String) failed to find "
- + new File(repositoriesFolder, repositoryName).getAbsolutePath());
+ if (logError) {
+ logger.error("GitBlit.getRepository(String) failed to find "
+ + new File(repositoriesFolder, repositoryName).getAbsolutePath());
+ }
} catch (ServiceNotAuthorizedException e) {
r = null;
- logger.error("GitBlit.getRepository(String) failed to find "
- + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);
+ if (logError) {
+ logger.error("GitBlit.getRepository(String) failed to find "
+ + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);
+ }
} catch (ServiceNotEnabledException e) {
r = null;
- logger.error("GitBlit.getRepository(String) failed to find "
- + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);
+ if (logError) {
+ logger.error("GitBlit.getRepository(String) failed to find "
+ + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);
+ }
}
return r;
}
@@ -991,14 +1009,14 @@
config.setString("gitblit", null, "federationStrategy",
repository.federationStrategy.name());
config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
- if (repository.preReceiveScripts != null) {
+ if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
}
- if (repository.postReceiveScripts != null) {
+ if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
config.setStringList("gitblit", null, "postReceiveScript",
repository.postReceiveScripts);
}
- if (repository.mailingLists != null) {
+ if (!ArrayUtils.isEmpty(repository.mailingLists)) {
config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
}
try {
@@ -1741,9 +1759,7 @@
try {
// check to see if this "file" is a login service class
Class<?> realmClass = Class.forName(realm);
- if (IUserService.class.isAssignableFrom(realmClass)) {
- loginService = (IUserService) realmClass.newInstance();
- }
+ loginService = (IUserService) realmClass.newInstance();
} catch (Throwable t) {
loginService = new GitblitUserService();
}
@@ -1787,6 +1803,21 @@
webxmlSettings.applyOverrides(overrideFile);
}
configureContext(webxmlSettings, true);
+
+ // Copy the included scripts to the configured groovy folder
+ File localScripts = getFileOrFolder(Keys.groovy.scriptsFolder, "groovy");
+ if (!localScripts.exists()) {
+ File includedScripts = new File(context.getRealPath("/WEB-INF/groovy"));
+ if (!includedScripts.equals(localScripts)) {
+ try {
+ com.gitblit.utils.FileUtils.copy(localScripts, includedScripts.listFiles());
+ } catch (IOException e) {
+ logger.error(MessageFormat.format(
+ "Failed to copy included Groovy scripts from {0} to {1}",
+ includedScripts, localScripts));
+ }
+ }
+ }
}
serverStatus.servletContainer = servletContext.getServerInfo();
--
Gitblit v1.9.1