From 117a2e4a11d8f88c32a58d0565f629bddeee7a6b Mon Sep 17 00:00:00 2001 From: Tomas Bjerre Date: Mon, 20 Nov 2017 20:12:15 +0100 Subject: [PATCH] Support for delete-event #259 --- .travis.yml | 4 +- CHANGELOG.md | 11 ++++++ pom.xml | 2 +- .../listener/PrnfbPullRequestAction.java | 11 +++--- .../PrnfbPullRequestEventListener.java | 38 +++++++++++-------- src/main/resources/admin.vm | 4 ++ 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index b240b09b..2844b5b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,10 @@ before_install: - ./setup-atlassian-sdk.sh `pwd` - export PATH=opt/atlassian-plugin-sdk/bin:opt/atlassian-plugin-sdk/apache-maven-*/bin:$PATH install: - - atlas-mvn -q install -Dbitbucket.version=5.0.0 + - atlas-mvn -q install -Dbitbucket.version=5.1.0 - atlas-mvn -q install script: - - atlas-package -q -Dbitbucket.version=5.0.0 + - atlas-package -q -Dbitbucket.version=5.1.0 - atlas-package -q notifications: email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f2f865..8187d51a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ Changelog of Pull Request Notifier for Bitbucket. +## Unreleased +### GitHub [#259](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/259) Trigger for pull request DELETE + Support for delete-event + + [02351bb60c95058](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/02351bb60c95058) Tomas Bjerre *2017-11-20 19:14:02* + +### No issue + Doc + + [e3ab153867fabb3](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/e3ab153867fabb3) Tomas Bjerre *2017-11-18 17:31:17* + ## 3.17 ### GitHub [#257](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/257) Bitbucket - OpenShift Integration Adding HTTP 1.1 support diff --git a/pom.xml b/pom.xml index 83ad080c..edd56c02 100644 --- a/pom.xml +++ b/pom.xml @@ -281,7 +281,7 @@ Changelog of Pull Request Notifier for Bitbucket. - 5.2.2 + 5.5.1 ${bitbucket.version} 2.0.0 6.3.0 diff --git a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestAction.java b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestAction.java index 9e4c01a6..f3fc1e62 100644 --- a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestAction.java +++ b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestAction.java @@ -1,14 +1,15 @@ package se.bjurr.prnfb.listener; +import se.bjurr.prnfb.settings.PrnfbNotification; + import com.atlassian.bitbucket.event.pull.PullRequestEvent; import com.atlassian.bitbucket.event.pull.PullRequestRescopedEvent; -import se.bjurr.prnfb.settings.PrnfbNotification; - public enum PrnfbPullRequestAction { APPROVED, // BUTTON_TRIGGER, // COMMENTED, // + DELETED, // DECLINED, // MERGED, // OPENED, // @@ -23,12 +24,12 @@ public enum PrnfbPullRequestAction { public static PrnfbPullRequestAction fromPullRequestEvent( PullRequestEvent event, PrnfbNotification notification) { if (event instanceof PullRequestRescopedEvent) { - PullRequestRescopedEvent rescopedEvent = (PullRequestRescopedEvent) event; - boolean toChanged = + final PullRequestRescopedEvent rescopedEvent = (PullRequestRescopedEvent) event; + final boolean toChanged = !rescopedEvent .getPreviousToHash() .equals(rescopedEvent.getPullRequest().getToRef().getLatestCommit()); - boolean fromChanged = + final boolean fromChanged = !rescopedEvent .getPreviousFromHash() .equals(rescopedEvent.getPullRequest().getFromRef().getLatestCommit()); diff --git a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java index 18a374ea..d6791812 100644 --- a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java +++ b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java @@ -17,6 +17,22 @@ import org.slf4j.Logger; +import se.bjurr.prnfb.http.ClientKeyStore; +import se.bjurr.prnfb.http.HttpResponse; +import se.bjurr.prnfb.http.Invoker; +import se.bjurr.prnfb.http.NotificationResponse; +import se.bjurr.prnfb.http.UrlInvoker; +import se.bjurr.prnfb.service.PrnfbRenderer; +import se.bjurr.prnfb.service.PrnfbRenderer.ENCODE_FOR; +import se.bjurr.prnfb.service.PrnfbRendererFactory; +import se.bjurr.prnfb.service.SettingsService; +import se.bjurr.prnfb.service.VariablesContext; +import se.bjurr.prnfb.service.VariablesContext.VariablesContextBuilder; +import se.bjurr.prnfb.settings.PrnfbHeader; +import se.bjurr.prnfb.settings.PrnfbNotification; +import se.bjurr.prnfb.settings.PrnfbSettingsData; +import se.bjurr.prnfb.settings.TRIGGER_IF_MERGE; + import com.atlassian.bitbucket.ServiceException; import com.atlassian.bitbucket.event.pull.PullRequestCommentAddedEvent; import com.atlassian.bitbucket.event.pull.PullRequestCommentDeletedEvent; @@ -24,6 +40,7 @@ import com.atlassian.bitbucket.event.pull.PullRequestCommentEvent; import com.atlassian.bitbucket.event.pull.PullRequestCommentRepliedEvent; import com.atlassian.bitbucket.event.pull.PullRequestDeclinedEvent; +import com.atlassian.bitbucket.event.pull.PullRequestDeletedEvent; import com.atlassian.bitbucket.event.pull.PullRequestEvent; import com.atlassian.bitbucket.event.pull.PullRequestMergedEvent; import com.atlassian.bitbucket.event.pull.PullRequestOpenedEvent; @@ -43,22 +60,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; -import se.bjurr.prnfb.http.ClientKeyStore; -import se.bjurr.prnfb.http.HttpResponse; -import se.bjurr.prnfb.http.Invoker; -import se.bjurr.prnfb.http.NotificationResponse; -import se.bjurr.prnfb.http.UrlInvoker; -import se.bjurr.prnfb.service.PrnfbRenderer; -import se.bjurr.prnfb.service.PrnfbRenderer.ENCODE_FOR; -import se.bjurr.prnfb.service.PrnfbRendererFactory; -import se.bjurr.prnfb.service.SettingsService; -import se.bjurr.prnfb.service.VariablesContext; -import se.bjurr.prnfb.service.VariablesContext.VariablesContextBuilder; -import se.bjurr.prnfb.settings.PrnfbHeader; -import se.bjurr.prnfb.settings.PrnfbNotification; -import se.bjurr.prnfb.settings.PrnfbSettingsData; -import se.bjurr.prnfb.settings.TRIGGER_IF_MERGE; - public class PrnfbPullRequestEventListener { private static final Logger LOG = getLogger(PrnfbPullRequestEventListener.class); @@ -357,6 +358,11 @@ public void onEvent(final PullRequestCommentRepliedEvent e) { handleEventAsync(e); } + @EventListener + public void onEvent(final PullRequestDeletedEvent e) { + handleEventAsync(e); + } + @EventListener public void onEvent(final PullRequestDeclinedEvent e) { handleEventAsync(e); diff --git a/src/main/resources/admin.vm b/src/main/resources/admin.vm index fbed91eb..34c34510 100644 --- a/src/main/resources/admin.vm +++ b/src/main/resources/admin.vm @@ -422,6 +422,10 @@ +
+ +