Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Support for delete-event #259
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Nov 20, 2017
1 parent e3ab153 commit 117a2e4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Changelog of Pull Request Notifier for Bitbucket.
</profiles>

<properties>
<bitbucket.version>5.2.2</bitbucket.version>
<bitbucket.version>5.5.1</bitbucket.version>
<bitbucket.data.version>${bitbucket.version}</bitbucket.data.version>
<quick.reload.version>2.0.0</quick.reload.version>
<amps.version>6.3.0</amps.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -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, //
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,30 @@

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;
import com.atlassian.bitbucket.event.pull.PullRequestCommentEditedEvent;
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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@
<label>
<input class="checkbox" type="checkbox" name="triggers[]" value="DECLINED">DECLINED</label>
</div>
<div class="checkbox">
<label>
<input class="checkbox" type="checkbox" name="triggers[]" value="DELETED">DELETED</label>
</div>
<div class="checkbox">
<label>
<input class="checkbox" type="checkbox" name="triggers[]" value="MERGED">MERGED</label>
Expand Down

0 comments on commit 117a2e4

Please sign in to comment.