summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-03-29 10:49:37 -0400
committerJames Moger <james.moger@gitblit.com>2013-03-29 10:49:37 -0400
commite5c14e6d7e24bbf6807a65e56560a13e7bd7eca3 (patch)
tree5833121965872353915defeaf0d58aaf1e69502c /src
parent0f3cb24604e7c3c1a78d5b97f6f4fce6f796b510 (diff)
downloadgitblit-e5c14e6d7e24bbf6807a65e56560a13e7bd7eca3.tar.gz
gitblit-e5c14e6d7e24bbf6807a65e56560a13e7bd7eca3.zip
Fixed NPE in FedClient and support --baseFolder in FedClient (issue 219)
Diffstat (limited to 'src')
-rw-r--r--src/main/distrib/federation.properties2
-rw-r--r--src/main/java/com/gitblit/FederationClient.java20
-rw-r--r--src/main/java/com/gitblit/FederationPullExecutor.java2
3 files changed, 17 insertions, 7 deletions
diff --git a/src/main/distrib/federation.properties b/src/main/distrib/federation.properties
index c762b45c..72058f06 100644
--- a/src/main/distrib/federation.properties
+++ b/src/main/distrib/federation.properties
@@ -8,7 +8,7 @@
#
# SINCE 0.5.0
# RESTART REQUIRED
-git.repositoriesFolder = git
+git.repositoriesFolder = ${baseFolder}/git
# Search the repositories folder subfolders for other repositories.
# Repositories MAY NOT be nested (i.e. one repository within another)
diff --git a/src/main/java/com/gitblit/FederationClient.java b/src/main/java/com/gitblit/FederationClient.java
index 4aeb2111..d34aadbd 100644
--- a/src/main/java/com/gitblit/FederationClient.java
+++ b/src/main/java/com/gitblit/FederationClient.java
@@ -44,7 +44,16 @@ public class FederationClient {
usage(jc, t);
}
- IStoredSettings settings = new FileSettings(params.registrationsFile);
+ System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
+
+ // command-line specified base folder
+ File baseFolder = new File(System.getProperty("user.dir"));
+ if (!StringUtils.isEmpty(params.baseFolder)) {
+ baseFolder = new File(params.baseFolder);
+ }
+
+ File regFile = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.registrationsFile);
+ IStoredSettings settings = new FileSettings(regFile.getAbsolutePath());
List<FederationModel> registrations = new ArrayList<FederationModel>();
if (StringUtils.isEmpty(params.url)) {
registrations.addAll(FederationUtils.getFederationRegistrations(settings));
@@ -67,8 +76,6 @@ public class FederationClient {
System.exit(0);
}
- System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
-
// command-line specified repositories folder
if (!StringUtils.isEmpty(params.repositoriesFolder)) {
settings.overrideSetting(Keys.git.repositoriesFolder, new File(
@@ -76,7 +83,7 @@ public class FederationClient {
}
// configure the Gitblit singleton for minimal, non-server operation
- GitBlit.self().configureContext(settings, null, false);
+ GitBlit.self().configureContext(settings, baseFolder, false);
FederationPullExecutor executor = new FederationPullExecutor(registrations, params.isDaemon);
executor.run();
if (!params.isDaemon) {
@@ -106,7 +113,7 @@ public class FederationClient {
private static class Params {
@Parameter(names = { "--registrations" }, description = "Gitblit Federation Registrations File", required = false)
- public String registrationsFile = "federation.properties";
+ public String registrationsFile = "${baseFolder}/federation.properties";
@Parameter(names = { "--daemon" }, description = "Runs in daemon mode to schedule and pull repositories", required = false)
public boolean isDaemon;
@@ -126,6 +133,9 @@ public class FederationClient {
@Parameter(names = { "--frequency" }, description = "Period to wait between pull attempts (requires --daemon)", required = false)
public String frequency = "60 mins";
+ @Parameter(names = { "--baseFolder" }, description = "Base folder for received data", required = false)
+ public String baseFolder;
+
@Parameter(names = { "--repositoriesFolder" }, description = "Destination folder for cloned repositories", required = false)
public String repositoriesFolder;
diff --git a/src/main/java/com/gitblit/FederationPullExecutor.java b/src/main/java/com/gitblit/FederationPullExecutor.java
index ad1022cf..25cd32a5 100644
--- a/src/main/java/com/gitblit/FederationPullExecutor.java
+++ b/src/main/java/com/gitblit/FederationPullExecutor.java
@@ -153,7 +153,7 @@ public class FederationPullExecutor implements Runnable {
c, registrationFolder, registration.name));
return;
}
- File repositoriesFolder = new File(GitBlit.getString(Keys.git.repositoriesFolder, "git"));
+ File repositoriesFolder = GitBlit.getRepositoriesFolder();
File registrationFolderFile = new File(repositoriesFolder, registrationFolder);
registrationFolderFile.mkdirs();