From 5b29c53b326b5fd283cb06356e94df5f78508860 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 23 Mar 2012 16:35:48 -0400
Subject: [PATCH] Update indexed branches on federation pull
---
src/com/gitblit/FederationPullExecutor.java | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/com/gitblit/FederationPullExecutor.java b/src/com/gitblit/FederationPullExecutor.java
index d54395e..10f69d2 100644
--- a/src/com/gitblit/FederationPullExecutor.java
+++ b/src/com/gitblit/FederationPullExecutor.java
@@ -49,6 +49,7 @@
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.FederationUtils;
import com.gitblit.utils.FileUtils;
import com.gitblit.utils.JGitUtils;
@@ -271,6 +272,17 @@
federationSets.addAll(repository.federationSets);
}
repository.federationSets = new ArrayList<String>(federationSets);
+
+ // merge indexed branches
+ Set<String> indexedBranches = new HashSet<String>();
+ if (rm.indexedBranches != null) {
+ indexedBranches.addAll(rm.indexedBranches);
+ }
+ if (repository.indexedBranches != null) {
+ indexedBranches.addAll(repository.indexedBranches);
+ }
+ repository.indexedBranches = new ArrayList<String>(indexedBranches);
+
}
// only repositories that are actually _cloned_ from the origin
// Gitblit repository are marked as federated. If the origin
@@ -339,7 +351,7 @@
// update team repositories
TeamModel remoteTeam = user.getTeam(teamname);
- if (remoteTeam != null && remoteTeam.repositories != null) {
+ if (remoteTeam != null && !ArrayUtils.isEmpty(remoteTeam.repositories)) {
int before = team.repositories.size();
team.addRepositories(remoteTeam.repositories);
int after = team.repositories.size();
@@ -399,7 +411,7 @@
"Failed to retrieve SETTINGS from federated gitblit ({0} @ {1})",
registration.name, registration.url), e);
}
-
+
try {
// Pull SCRIPTS
Map<String, String> scripts = FederationUtils.getScripts(registration);
@@ -407,9 +419,10 @@
for (Map.Entry<String, String> script : scripts.entrySet()) {
String scriptName = script.getKey();
if (scriptName.endsWith(".groovy")) {
- scriptName = scriptName.substring(0, scriptName.indexOf(".groovy"));
+ scriptName = scriptName.substring(0, scriptName.indexOf(".groovy"));
}
- File file = new File(registrationFolderFile, registration.name + "_" + scriptName + ".groovy");
+ File file = new File(registrationFolderFile, registration.name + "_"
+ + scriptName + ".groovy");
FileUtils.writeContent(file, script.getValue());
}
}
--
Gitblit v1.9.1