summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/service
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2014-03-05 21:50:16 -0500
committerJames Moger <james.moger@gmail.com>2014-03-05 21:50:16 -0500
commite462bbf2974d33f1a5a0b2a808e150aa0e22d6f4 (patch)
tree9bf1f678197967c9b9fce399386cbb4cc10810fb /src/main/java/com/gitblit/service
parentf0950d6f8d663612574a436c99cf098322e825f0 (diff)
downloadgitblit-e462bbf2974d33f1a5a0b2a808e150aa0e22d6f4.tar.gz
gitblit-e462bbf2974d33f1a5a0b2a808e150aa0e22d6f4.zip
Fire an event on received ticket branch updates to trigger reindex
It would be useful to be able to push a complete repository with a refs/gitblit/tickets branch and have Gitblit index all those tickets. Additionally, it would be nice for the mirroring service to recognize an incoming update to this ref and fire an event that can be processed by the BranchTicketService, if so configured, to reindex the tickets.
Diffstat (limited to 'src/main/java/com/gitblit/service')
-rw-r--r--src/main/java/com/gitblit/service/MirrorService.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/service/MirrorService.java b/src/main/java/com/gitblit/service/MirrorService.java
index 9833d939..1eb54202 100644
--- a/src/main/java/com/gitblit/service/MirrorService.java
+++ b/src/main/java/com/gitblit/service/MirrorService.java
@@ -38,6 +38,8 @@ import com.gitblit.Keys;
import com.gitblit.manager.IRepositoryManager;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.tickets.BranchTicketService;
+import com.gitblit.tickets.BranchTicketService.TicketsBranchUpdated;
import com.gitblit.utils.JGitUtils;
/**
@@ -145,6 +147,7 @@ public class MirrorService implements Runnable {
FetchResult result = git.fetch().setRemote(mirror.getName()).setDryRun(testing).call();
Collection<TrackingRefUpdate> refUpdates = result.getTrackingRefUpdates();
if (refUpdates.size() > 0) {
+ boolean ticketBranchUpdated = false;
for (TrackingRefUpdate ru : refUpdates) {
StringBuilder sb = new StringBuilder();
sb.append("updated mirror ");
@@ -161,6 +164,14 @@ public class MirrorService implements Runnable {
sb.append("..");
sb.append(ru.getNewObjectId() == null ? "" : ru.getNewObjectId().abbreviate(7).name());
logger.info(sb.toString());
+
+ if (BranchTicketService.BRANCH.equals(ru.getLocalName())) {
+ ticketBranchUpdated = true;
+ }
+ }
+
+ if (ticketBranchUpdated) {
+ repository.fireEvent(new TicketsBranchUpdated(model));
}
}
} catch (Exception e) {