diff options
Diffstat (limited to 'src/main/java/com/gitblit/git/PatchsetReceivePack.java')
-rw-r--r-- | src/main/java/com/gitblit/git/PatchsetReceivePack.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java index 2c3b957b..77d5a71e 100644 --- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java +++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java @@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory; import com.gitblit.Constants;
import com.gitblit.Keys;
+import com.gitblit.extensions.PatchsetHook;
import com.gitblit.manager.IGitblit;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.TicketModel;
@@ -716,6 +717,15 @@ public class PatchsetReceivePack extends GitblitReceivePack { RefLogUtils.updateRefLog(user, getRepository(),
Arrays.asList(new ReceiveCommand(cmd.getOldId(), cmd.getNewId(), cmd.getRefName())));
+ // call any patchset hooks
+ for (PatchsetHook hook : gitblit.getExtensions(PatchsetHook.class)) {
+ try {
+ hook.onNewPatchset(ticket);
+ } catch (Exception e) {
+ LOGGER.error("Failed to execute extension", e);
+ }
+ }
+
return ticket;
} else {
sendError("FAILED to create ticket");
@@ -743,6 +753,20 @@ public class PatchsetReceivePack extends GitblitReceivePack { RefLogUtils.updateRefLog(user, getRepository(),
Arrays.asList(new ReceiveCommand(cmd.getOldId(), cmd.getNewId(), cmd.getRefName())));
+ // call any patchset hooks
+ final boolean isNewPatchset = change.patchset.rev == 1;
+ for (PatchsetHook hook : gitblit.getExtensions(PatchsetHook.class)) {
+ try {
+ if (isNewPatchset) {
+ hook.onNewPatchset(ticket);
+ } else {
+ hook.onUpdatePatchset(ticket);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Failed to execute extension", e);
+ }
+ }
+
// return the updated ticket
return ticket;
} else {
@@ -1167,6 +1191,15 @@ public class PatchsetReceivePack extends GitblitReceivePack { ObjectId.fromString(mergeResult.sha), oldRef.getName());
RefLogUtils.updateRefLog(user, getRepository(), Arrays.asList(cmd));
}
+
+ // call patchset hooks
+ for (PatchsetHook hook : gitblit.getExtensions(PatchsetHook.class)) {
+ try {
+ hook.onMergePatchset(ticket);
+ } catch (Exception e) {
+ LOGGER.error("Failed to execute extension", e);
+ }
+ }
return mergeResult.status;
} else {
LOGGER.error("FAILED to resolve ticket {} by merge from web ui", ticketId);
|