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

Commit a6fdac1

Browse files
committed
Determining conflicing state correctly #228
* PR has to be open in order to check if it can be merged. Any closed PR is now considered not conflicting.
1 parent 53b27e3 commit a6fdac1

File tree

12 files changed

+56
-102
lines changed

12 files changed

+56
-102
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@
33
Changelog of Pull Request Notifier for Bitbucket.
44

55
## Unreleased
6+
### GitHub [#226](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/226) REST API POST ISSUES
7+
Correcting markdown in REST-API
8+
9+
[5f555e903069e04](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/5f555e903069e04) Tomas Bjerre *2017-06-23 09:37:28*
10+
11+
### GitHub [#231](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/231) Typo "Optinoal" in admin.vm
12+
Typo "Optinoal" in admin.vm
13+
14+
[53b27e36155c764](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/53b27e36155c764) Tomas Bjerre *2017-07-12 05:25:41*
15+
616
### No issue
17+
Fixing compile error in Travis
18+
19+
[338ae4477962919](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/338ae4477962919) Tomas Bjerre *2017-06-02 08:38:13*
20+
721
doc
822

9-
[ddbf3b6a86162a9](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/ddbf3b6a86162a9) Tomas Bjerre *2017-06-02 07:56:38*
23+
[305d0711327e562](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/305d0711327e562) Tomas Bjerre *2017-06-02 08:07:02*
1024

1125
## 3.1
1226
### GitHub [#220](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/220) Feature: add PREVIOUS_FROM_HASH and PREVIOUS_TO_HASH to variables

docker-bash.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

docker-build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker-clean.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

docker-logs.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

docker-run.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

docker-stop.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

integration-test-local.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

integration-test.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,10 @@ public boolean isNotificationTriggeredByAction(
190190
return FALSE;
191191
}
192192

193-
if (notification.getTriggerIfCanMerge() != ALWAYS && pullRequest.isOpen()) {
193+
if (notification.getTriggerIfCanMerge() != ALWAYS) {
194194
// Cannot perform canMerge unless PR is open
195-
boolean isConflicted =
196-
securityService //
197-
.withPermission(ADMIN, "Can merge") //
198-
.call(
199-
new Operation<Boolean, RuntimeException>() {
200-
@Override
201-
public Boolean perform() throws RuntimeException {
202-
return pullRequestService //
203-
.canMerge(
204-
pullRequest.getToRef().getRepository().getId(),
205-
pullRequest.getId()) //
206-
.isConflicted();
207-
}
208-
});
195+
boolean notYetMerged = pullRequest.isOpen();
196+
boolean isConflicted = notYetMerged && hasConflicts(pullRequest);
209197
if (ignoreBecauseOfConflicting(notification.getTriggerIfCanMerge(), isConflicted)) {
210198
return FALSE;
211199
}
@@ -214,6 +202,21 @@ public Boolean perform() throws RuntimeException {
214202
return TRUE;
215203
}
216204

205+
private boolean hasConflicts(PullRequest pullRequest) {
206+
return securityService //
207+
.withPermission(ADMIN, "Can merge") //
208+
.call(
209+
new Operation<Boolean, RuntimeException>() {
210+
@Override
211+
public Boolean perform() throws RuntimeException {
212+
return pullRequestService //
213+
.canMerge(
214+
pullRequest.getToRef().getRepository().getId(), pullRequest.getId()) //
215+
.isConflicted();
216+
}
217+
});
218+
}
219+
217220
public NotificationResponse notify(
218221
final PrnfbNotification notification,
219222
PrnfbPullRequestAction pullRequestAction,

0 commit comments

Comments
 (0)