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

Commit

Permalink
Update UI & related references for better wording
Browse files Browse the repository at this point in the history
  • Loading branch information
rbywater committed Sep 11, 2017
1 parent 3e25186 commit cd4e861
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class NotificationDTO implements Comparable<NotificationDTO>, Restricted
private TRIGGER_IF_MERGE triggerIfCanMerge;
private List<String> triggerIgnoreStateList;
private List<String> triggers;
private boolean forceMergeOnRescope;
private boolean updatePullRequestRefs;
private String url;
private String user;
private UUID uuid;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -293,8 +293,8 @@ public List<String> getTriggers() {
return this.triggers;
}

public boolean isForceMergeOnRescope() {
return this.forceMergeOnRescope;
public boolean isUpdatePullRequestRefs() {
return this.updatePullRequestRefs;
}

public String getUrl() {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -413,8 +413,8 @@ public void setTriggers(List<String> 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) {
Expand Down Expand Up @@ -481,8 +481,8 @@ public String toString() {
+ triggerIgnoreStateList
+ ", triggers="
+ triggers
+ ", forceMergeOnRescope="
+ forceMergeOnRescope
+ ", updatePullRequestRefs="
+ updatePullRequestRefs
+ ", url="
+ url
+ ", user="
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/se/bjurr/prnfb/settings/PrnfbNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class PrnfbNotification implements HasUuid, Restricted {
private final TRIGGER_IF_MERGE triggerIfCanMerge;
private final List<PullRequestState> triggerIgnoreStateList;
private final List<PrnfbPullRequestAction> triggers;
private final boolean forceMergeOnRescope;
private final boolean updatePullRequestRefs;
private final String url;
private final String user;
private final UUID uuid;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -336,8 +336,8 @@ public List<PrnfbPullRequestAction> getTriggers() {
return this.triggers;
}

public boolean isForceMergeOnRescope() {
return this.forceMergeOnRescope;
public boolean isUpdatePullRequestRefs() {
return this.updatePullRequestRefs;
}

public String getUrl() {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -422,8 +422,8 @@ public String toString() {
+ triggerIgnoreStateList
+ ", triggers="
+ triggers
+ ", forceMergeOnRescope="
+ forceMergeOnRescope
+ ", updatePullRequestRefs="
+ updatePullRequestRefs
+ ", url="
+ url
+ ", user="
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/se/bjurr/prnfb/settings/PrnfbNotificationBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public PrnfbNotificationBuilder(
TRIGGER_IF_MERGE triggerIfCanMerge,
List<PullRequestState> triggerIgnoreStateList,
List<PrnfbPullRequestAction> triggers,
boolean forceMergeOnRescope,
boolean updatePullRequestRefs,
String url,
String user,
UUID uuid,
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -119,7 +119,7 @@ public static PrnfbNotificationBuilder prnfbNotificationBuilder(PrnfbNotificatio
private TRIGGER_IF_MERGE triggerIfCanMerge;
private List<PullRequestState> triggerIgnoreStateList = newArrayList();
private List<PrnfbPullRequestAction> triggers = newArrayList();
private boolean forceMergeOnRescope;
private boolean updatePullRequestRefs;
private String url;
private String user;
private UUID uuid;
Expand Down Expand Up @@ -214,8 +214,8 @@ public List<PrnfbPullRequestAction> getTriggers() {
return this.triggers;
}

public boolean isForceMergeOnRescope() {
return this.forceMergeOnRescope;
public boolean isUpdatePullRequestRefs() {
return this.updatePullRequestRefs;
}

public String getUrl() {
Expand Down Expand Up @@ -250,8 +250,8 @@ public PrnfbNotificationBuilder setTriggers(List<PrnfbPullRequestAction> trigger
return this;
}

public PrnfbNotificationBuilder setForceMergeOnRescope(boolean forceMergeOnRescope) {
this.forceMergeOnRescope = forceMergeOnRescope;
public PrnfbNotificationBuilder setUpdatePullRequestRefs(boolean updatePullRequestRefs) {
this.updatePullRequestRefs = updatePullRequestRefs;
return this;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()) //
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,13 @@

<fieldset class="group">
<legend>
<span>Force Merge on Rescope</span>
<span>Update Pull Request References</span>
</legend>
<div class="checkbox">
<input class="checkbox" type="checkbox" name="forceMergeOnRescope" value="true">
<input class="checkbox" type="checkbox" name="updatePullRequestRefs" value="true">&nbsp;
</div>
<div class="description">
Will update refs/pull-requests/{id}/from and refs/pull-requests/{id}/merge references in Git when Pull Request is rescoped.
</div>
</fieldset>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<PrnfbNotification> notifications =
newArrayList(notification1, notification2, notification3);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cd4e861

Please sign in to comment.