From cd4e861886977c56f8da3df4b805097c47ef35c4 Mon Sep 17 00:00:00 2001 From: Richard Bywater Date: Mon, 11 Sep 2017 17:13:21 +1200 Subject: [PATCH] Update UI & related references for better wording --- .../PrnfbPullRequestEventListener.java | 2 +- .../presentation/dto/NotificationDTO.java | 18 ++++++++--------- .../prnfb/settings/PrnfbNotification.java | 16 +++++++-------- .../settings/PrnfbNotificationBuilder.java | 20 +++++++++---------- .../transformer/NotificationTransformer.java | 4 ++-- src/main/resources/admin.vm | 7 +++++-- .../PrnfbPullRequestEventListenerTest.java | 7 +++---- 7 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java index 0d9d61d..879df99 100644 --- a/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java +++ b/src/main/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListener.java @@ -119,7 +119,7 @@ private void handleEvent(final PullRequestEvent pullRequestEvent) { try { if (!pullRequest.isClosed() && pullRequestEvent.getAction().equals(PullRequestAction.RESCOPED) - && notification.isForceMergeOnRescope() + && notification.isUpdatePullRequestRefs() && !mergePerformed) { mergePerformed = true; try { diff --git a/src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java b/src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java index 9982d84..25724a4 100644 --- a/src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java +++ b/src/main/java/se/bjurr/prnfb/presentation/dto/NotificationDTO.java @@ -37,7 +37,7 @@ public class NotificationDTO implements Comparable, Restricted private TRIGGER_IF_MERGE triggerIfCanMerge; private List triggerIgnoreStateList; private List triggers; - private boolean forceMergeOnRescope; + private boolean updatePullRequestRefs; private String url; private String user; private UUID uuid; @@ -192,7 +192,7 @@ public boolean equals(Object obj) { } else if (!triggers.equals(other.triggers)) { return false; } - if (forceMergeOnRescope != other.forceMergeOnRescope) { + if (updatePullRequestRefs != other.updatePullRequestRefs) { return false; } if (url == null) { @@ -293,8 +293,8 @@ public List getTriggers() { return this.triggers; } - public boolean isForceMergeOnRescope() { - return this.forceMergeOnRescope; + public boolean isUpdatePullRequestRefs() { + return this.updatePullRequestRefs; } public String getUrl() { @@ -334,7 +334,7 @@ public int hashCode() { result = prime * result + (triggerIgnoreStateList == null ? 0 : triggerIgnoreStateList.hashCode()); result = prime * result + (triggers == null ? 0 : triggers.hashCode()); - result = prime * result + (forceMergeOnRescope ? 1 : 0); + result = prime * result + (updatePullRequestRefs ? 1 : 0); result = prime * result + (url == null ? 0 : url.hashCode()); result = prime * result + (user == null ? 0 : user.hashCode()); result = prime * result + (uuid == null ? 0 : uuid.hashCode()); @@ -413,8 +413,8 @@ public void setTriggers(List triggers) { this.triggers = triggers; } - public void setForceMergeOnRescope(boolean forceMergeOnRescope) { - this.forceMergeOnRescope = forceMergeOnRescope; + public void setUpdatePullRequestRefs(boolean updatePullRequestRefs) { + this.updatePullRequestRefs = updatePullRequestRefs; } public void setUrl(String url) { @@ -481,8 +481,8 @@ public String toString() { + triggerIgnoreStateList + ", triggers=" + triggers - + ", forceMergeOnRescope=" - + forceMergeOnRescope + + ", updatePullRequestRefs=" + + updatePullRequestRefs + ", url=" + url + ", user=" diff --git a/src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java b/src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java index 4615245..7aed3a6 100644 --- a/src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java +++ b/src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java @@ -44,7 +44,7 @@ public class PrnfbNotification implements HasUuid, Restricted { private final TRIGGER_IF_MERGE triggerIfCanMerge; private final List triggerIgnoreStateList; private final List triggers; - private final boolean forceMergeOnRescope; + private final boolean updatePullRequestRefs; private final String url; private final String user; private final UUID uuid; @@ -88,7 +88,7 @@ public PrnfbNotification(PrnfbNotificationBuilder builder) throws ValidationExce if (this.triggers.isEmpty()) { throw new ValidationException("triggers", "At least one trigger must be selected."); } - this.forceMergeOnRescope = builder.isForceMergeOnRescope(); + this.updatePullRequestRefs = builder.isUpdatePullRequestRefs(); this.filterString = emptyToNull(nullToEmpty(builder.getFilterString()).trim()); this.filterRegexp = emptyToNull(nullToEmpty(builder.getFilterRegexp()).trim()); this.name = firstNonNull(emptyToNull(nullToEmpty(builder.getName()).trim()), DEFAULT_NAME); @@ -231,7 +231,7 @@ public boolean equals(Object obj) { } else if (!triggers.equals(other.triggers)) { return false; } - if (forceMergeOnRescope != other.forceMergeOnRescope) { + if (updatePullRequestRefs != other.updatePullRequestRefs) { return false; } if (url == null) { @@ -336,8 +336,8 @@ public List getTriggers() { return this.triggers; } - public boolean isForceMergeOnRescope() { - return this.forceMergeOnRescope; + public boolean isUpdatePullRequestRefs() { + return this.updatePullRequestRefs; } public String getUrl() { @@ -377,7 +377,7 @@ public int hashCode() { result = prime * result + (triggerIgnoreStateList == null ? 0 : triggerIgnoreStateList.hashCode()); result = prime * result + (triggers == null ? 0 : triggers.hashCode()); - result = prime * result + (forceMergeOnRescope ? 1 : 0); + result = prime * result + (updatePullRequestRefs ? 1 : 0); result = prime * result + (url == null ? 0 : url.hashCode()); result = prime * result + (user == null ? 0 : user.hashCode()); result = prime * result + (uuid == null ? 0 : uuid.hashCode()); @@ -422,8 +422,8 @@ public String toString() { + triggerIgnoreStateList + ", triggers=" + triggers - + ", forceMergeOnRescope=" - + forceMergeOnRescope + + ", updatePullRequestRefs=" + + updatePullRequestRefs + ", url=" + url + ", user=" diff --git a/src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java b/src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java index 4b95cb2..32977c5 100644 --- a/src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java +++ b/src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java @@ -39,7 +39,7 @@ public PrnfbNotificationBuilder( TRIGGER_IF_MERGE triggerIfCanMerge, List triggerIgnoreStateList, List triggers, - boolean forceMergeOnRescope, + boolean updatePullRequestRefs, String url, String user, UUID uuid, @@ -63,7 +63,7 @@ public PrnfbNotificationBuilder( this.triggerIfCanMerge = triggerIfCanMerge; this.triggerIgnoreStateList = triggerIgnoreStateList; this.triggers = triggers; - this.forceMergeOnRescope = forceMergeOnRescope; + this.updatePullRequestRefs = updatePullRequestRefs; this.url = url; this.user = user; this.uuid = uuid; @@ -77,7 +77,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio b.uuid = from.getUuid(); b.password = from.getPassword().orNull(); b.triggers = from.getTriggers(); - b.forceMergeOnRescope = from.isForceMergeOnRescope(); + b.updatePullRequestRefs = from.isUpdatePullRequestRefs(); b.url = from.getUrl(); b.user = from.getUser().orNull(); b.filterRegexp = from.getFilterRegexp().orNull(); @@ -119,7 +119,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio private TRIGGER_IF_MERGE triggerIfCanMerge; private List triggerIgnoreStateList = newArrayList(); private List triggers = newArrayList(); - private boolean forceMergeOnRescope; + private boolean updatePullRequestRefs; private String url; private String user; private UUID uuid; @@ -214,8 +214,8 @@ public List getTriggers() { return this.triggers; } - public boolean isForceMergeOnRescope() { - return this.forceMergeOnRescope; + public boolean isUpdatePullRequestRefs() { + return this.updatePullRequestRefs; } public String getUrl() { @@ -250,8 +250,8 @@ public PrnfbNotificationBuilder setTriggers(List trigger return this; } - public PrnfbNotificationBuilder setForceMergeOnRescope(boolean forceMergeOnRescope) { - this.forceMergeOnRescope = forceMergeOnRescope; + public PrnfbNotificationBuilder setUpdatePullRequestRefs(boolean updatePullRequestRefs) { + this.updatePullRequestRefs = updatePullRequestRefs; return this; } @@ -335,8 +335,8 @@ public PrnfbNotificationBuilder withTrigger(PrnfbPullRequestAction trigger) { return this; } - public PrnfbNotificationBuilder withForceMergeOnRescope(boolean forceMergeOnRescope) { - this.forceMergeOnRescope = forceMergeOnRescope; + public PrnfbNotificationBuilder withUpdatePullRequestRefs(boolean updatePullRequestRefs) { + this.updatePullRequestRefs = updatePullRequestRefs; return this; } diff --git a/src/main/java/se/bjurr/prnfb/transformer/NotificationTransformer.java b/src/main/java/se/bjurr/prnfb/transformer/NotificationTransformer.java index 79bbf07..bd3b25c 100644 --- a/src/main/java/se/bjurr/prnfb/transformer/NotificationTransformer.java +++ b/src/main/java/se/bjurr/prnfb/transformer/NotificationTransformer.java @@ -39,7 +39,7 @@ public static NotificationDTO toNotificationDto(PrnfbNotification from) { to.setTriggerIfCanMerge(from.getTriggerIfCanMerge()); to.setTriggerIgnoreStateList(toPullRequestStateStrings(from.getTriggerIgnoreStateList())); to.setTriggers(toStrings(from.getTriggers())); - to.setForceMergeOnRescope(from.isForceMergeOnRescope()); + to.setUpdatePullRequestRefs(from.isUpdatePullRequestRefs()); to.setUrl(from.getUrl()); to.setUser(UNCHANGED); to.setPassword(UNCHANGED); @@ -76,7 +76,7 @@ public static PrnfbNotification toPrnfbNotification(NotificationDTO from) .withProxySchema(from.getProxySchema()) // .withProxyUser(from.getProxyUser()) // .setTriggers(toPrnfbPullRequestActions(from.getTriggers())) // - .withForceMergeOnRescope(from.isForceMergeOnRescope()) // + .withUpdatePullRequestRefs(from.isUpdatePullRequestRefs()) // .withTriggerIfCanMerge(from.getTriggerIfCanMerge()) // .setTriggerIgnoreState(toPullRequestStates(from.getTriggerIgnoreStateList())) // .withUrl(from.getUrl()) // diff --git a/src/main/resources/admin.vm b/src/main/resources/admin.vm index e279c7b..dc6d84f 100644 --- a/src/main/resources/admin.vm +++ b/src/main/resources/admin.vm @@ -462,10 +462,13 @@
- Force Merge on Rescope + Update Pull Request References
- +   +
+
+ Will update refs/pull-requests/{id}/from and refs/pull-requests/{id}/merge references in Git when Pull Request is rescoped.
diff --git a/src/test/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListenerTest.java b/src/test/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListenerTest.java index 173489b..199c5fa 100644 --- a/src/test/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListenerTest.java +++ b/src/test/java/se/bjurr/prnfb/listener/PrnfbPullRequestEventListenerTest.java @@ -20,11 +20,9 @@ import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; -import com.atlassian.bitbucket.event.pull.PullRequestRescopedEvent; import com.atlassian.bitbucket.scm.Command; import com.atlassian.bitbucket.scm.ScmService; import com.atlassian.bitbucket.scm.pull.ScmPullRequestCommandFactory; @@ -177,7 +175,7 @@ public HttpResponse invoke(UrlInvoker urlInvoker) { prnfbNotificationBuilder(notification1) // .withUrl("http://not2.com/") // .withTrigger(PrnfbPullRequestAction.RESCOPED_FROM) // - .withForceMergeOnRescope(true) // + .withUpdatePullRequestRefs(true) // .build(); List notifications = newArrayList(notification1, notification2, notification3); @@ -511,7 +509,8 @@ public void testThatPullRequestOpenedCanTriggerNotification() { } @Test - public void testThatTryMergeIsCalledWhenForceMergeOnRescopeEnabled() throws ValidationException { + public void testThatTryMergeIsCalledWhenUpdatePullRequestRefsEnabled() + throws ValidationException { when(scmService.getPullRequestCommandFactory(any(PullRequest.class))) .thenReturn(pullRequestCommandFactory); when(pullRequestCommandFactory.tryMerge(any(PullRequest.class))).thenReturn(pullRequestCommand);