diff options
author | James Moger <james.moger@gitblit.com> | 2014-03-06 13:36:23 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-03-06 13:36:23 -0500 |
commit | 9883341c1fbb35abcb7a1d09f93f6a9e805ea551 (patch) | |
tree | 861c1aeb430e2c8a896873ad249734ebf5e4701c /src/main/java/com/gitblit/service | |
parent | e462bbf2974d33f1a5a0b2a808e150aa0e22d6f4 (diff) | |
download | gitblit-9883341c1fbb35abcb7a1d09f93f6a9e805ea551.tar.gz gitblit-9883341c1fbb35abcb7a1d09f93f6a9e805ea551.zip |
Revise push/mirror tickets branch triggering
Diffstat (limited to 'src/main/java/com/gitblit/service')
-rw-r--r-- | src/main/java/com/gitblit/service/MirrorService.java | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/main/java/com/gitblit/service/MirrorService.java b/src/main/java/com/gitblit/service/MirrorService.java index 1eb54202..cf9ccb55 100644 --- a/src/main/java/com/gitblit/service/MirrorService.java +++ b/src/main/java/com/gitblit/service/MirrorService.java @@ -28,6 +28,8 @@ import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.FetchResult;
+import org.eclipse.jgit.transport.ReceiveCommand;
+import org.eclipse.jgit.transport.ReceiveCommand.Type;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.TrackingRefUpdate;
import org.slf4j.Logger;
@@ -35,11 +37,11 @@ import org.slf4j.LoggerFactory; import com.gitblit.IStoredSettings;
import com.gitblit.Keys;
+import com.gitblit.git.ReceiveCommandEvent;
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;
/**
@@ -147,7 +149,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;
+ ReceiveCommand ticketBranchCmd = null;
for (TrackingRefUpdate ru : refUpdates) {
StringBuilder sb = new StringBuilder();
sb.append("updated mirror ");
@@ -164,14 +166,33 @@ 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;
+ ReceiveCommand.Type type = null;
+ switch (ru.getResult()) {
+ case NEW:
+ type = Type.CREATE;
+ break;
+ case FAST_FORWARD:
+ type = Type.UPDATE;
+ break;
+ case FORCED:
+ type = Type.UPDATE_NONFASTFORWARD;
+ break;
+ default:
+ type = null;
+ break;
+ }
+
+ if (type != null) {
+ ticketBranchCmd = new ReceiveCommand(ru.getOldObjectId(),
+ ru.getNewObjectId(), ru.getLocalName(), type);
+ }
}
}
-
- if (ticketBranchUpdated) {
- repository.fireEvent(new TicketsBranchUpdated(model));
+
+ if (ticketBranchCmd != null) {
+ repository.fireEvent(new ReceiveCommandEvent(model, ticketBranchCmd));
}
}
} catch (Exception e) {
|