summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/git
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/git
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/git')
-rw-r--r--src/main/java/com/gitblit/git/GitblitReceivePack.java9
-rw-r--r--src/main/java/com/gitblit/git/PatchsetReceivePack.java10
2 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/gitblit/git/GitblitReceivePack.java b/src/main/java/com/gitblit/git/GitblitReceivePack.java
index 3a0eff22..605632cf 100644
--- a/src/main/java/com/gitblit/git/GitblitReceivePack.java
+++ b/src/main/java/com/gitblit/git/GitblitReceivePack.java
@@ -51,6 +51,7 @@ import com.gitblit.manager.IGitblit;
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.ArrayUtils;
import com.gitblit.utils.ClientLogger;
import com.gitblit.utils.CommitCache;
@@ -343,6 +344,14 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
} catch (Exception e) {
LOGGER.error(MessageFormat.format("Failed to update {0} pushlog", repository.name), e);
}
+
+ // check for updates pushed to the BranchTicketService branch
+ for (ReceiveCommand cmd : commands) {
+ if (Result.OK.equals(cmd.getResult())
+ && BranchTicketService.BRANCH.equals(cmd.getRefName())) {
+ rp.getRepository().fireEvent(new TicketsBranchUpdated(repository));
+ }
+ }
// run Groovy hook scripts
Set<String> scripts = new LinkedHashSet<String>();
diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java
index ae429d2e..2044f604 100644
--- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java
+++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java
@@ -436,10 +436,12 @@ public class PatchsetReceivePack extends GitblitReceivePack {
case CREATE:
case UPDATE:
case UPDATE_NONFASTFORWARD:
- Collection<TicketModel> tickets = processMergedTickets(cmd);
- ticketsProcessed += tickets.size();
- for (TicketModel ticket : tickets) {
- ticketNotifier.queueMailing(ticket);
+ if (cmd.getRefName().startsWith(Constants.R_HEADS)) {
+ Collection<TicketModel> tickets = processMergedTickets(cmd);
+ ticketsProcessed += tickets.size();
+ for (TicketModel ticket : tickets) {
+ ticketNotifier.queueMailing(ticket);
+ }
}
break;
default: