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

Commit 8579a9d

Browse files
committed
Hash of merged commit (only available for merged-event) #75
1 parent dbc61b1 commit 8579a9d

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Changelog of Pull Request Notifier for Stash.
44

5+
## 1.33
6+
* New variables
7+
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
8+
59
## 1.32
610
* New variables
711
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The filter text as well as the URL support variables. These are:
5858
* ${PULL_REQUEST_AUTHOR_ID} Example: 1
5959
* ${PULL_REQUEST_AUTHOR_NAME} Example: admin
6060
* ${PULL_REQUEST_AUTHOR_SLUG} Example: admin
61+
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
6162
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
6263
* ${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT} Number of participants that approved the PR.
6364
* ${PULL_REQUEST_FROM_SSH_CLONE_URL} Example: ssh://git@localhost:7999/project_1/rep_1

src/main/java/se/bjurr/prnfs/listener/PrnfsPullRequestEventListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static se.bjurr.prnfs.admin.AdminFormValues.TRIGGER_IF_MERGE.NOT_CONFLICTING;
1414
import static se.bjurr.prnfs.listener.PrnfsPullRequestAction.fromPullRequestEvent;
1515
import static se.bjurr.prnfs.listener.PrnfsRenderer.PrnfsVariable.PULL_REQUEST_COMMENT_TEXT;
16+
import static se.bjurr.prnfs.listener.PrnfsRenderer.PrnfsVariable.PULL_REQUEST_MERGE_COMMIT;
1617
import static se.bjurr.prnfs.listener.UrlInvoker.urlInvoker;
1718
import static se.bjurr.prnfs.settings.SettingsStorage.getPrnfsSettings;
1819

@@ -142,7 +143,15 @@ public String get() {
142143
return ((PullRequestCommentAddedEvent) pullRequestEvent).getComment().getText();
143144
}
144145
});
146+
} else if (pullRequestEvent instanceof PullRequestMergedEvent) {
147+
variables.put(PULL_REQUEST_MERGE_COMMIT, new Supplier<String>() {
148+
@Override
149+
public String get() {
150+
return ((PullRequestMergedEvent) pullRequestEvent).getCommit().getId();
151+
}
152+
});
145153
}
154+
146155
PrnfsRenderer renderer = new PrnfsRenderer(pullRequestEvent.getPullRequest(), action, pullRequestEvent.getUser(),
147156
repositoryService, propertiesService, notification, variables);
148157
notify(notification, action, pullRequestEvent.getPullRequest(), variables, renderer);

src/main/java/se/bjurr/prnfs/listener/PrnfsRenderer.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ public String resolve(PullRequest pullRequest, PrnfsPullRequestAction prnfsPullR
258258
PrnfsNotification prnfsNotification, Map<PrnfsRenderer.PrnfsVariable, Supplier<String>> variables) {
259259
return getOrEmpty(variables, PULL_REQUEST_COMMENT_TEXT);
260260
}
261+
}), PULL_REQUEST_MERGE_COMMIT(new Resolver() {
262+
@Override
263+
public String resolve(PullRequest pullRequest, PrnfsPullRequestAction prnfsPullRequestAction, StashUser stashUser,
264+
RepositoryService repositoryService, ApplicationPropertiesService propertiesService,
265+
PrnfsNotification prnfsNotification, Map<PrnfsRenderer.PrnfsVariable, Supplier<String>> variables) {
266+
return getOrEmpty(variables, PULL_REQUEST_MERGE_COMMIT);
267+
}
261268
}), PULL_REQUEST_USER_DISPLAY_NAME(new Resolver() {
262269
@Override
263270
public String resolve(PullRequest pullRequest, PrnfsPullRequestAction prnfsPullRequestAction, StashUser stashUser,
@@ -350,7 +357,7 @@ public String resolve(PullRequest pullRequest, PrnfsPullRequestAction pullReques
350357
return Integer.toString(newArrayList(filter(pullRequest.getParticipants(), isApproved)).size());
351358
}
352359
});
353-
;
360+
354361
private static final Predicate<PullRequestParticipant> isApproved = new Predicate<PullRequestParticipant>() {
355362
@Override
356363
public boolean apply(PullRequestParticipant input) {

src/main/resources/admin.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<li><b>${PULL_REQUEST_AUTHOR_SLUG}</b> Example: admin</li>
5959
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}</b> Number of reviewers that approved the PR.</li>
6060
<li><b>${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}</b> Number of participants that approved the PR.</li>
61+
<li><b>${PULL_REQUEST_MERGE_COMMIT}</b> Hash of merged commit (only available for merged-event).</li>
6162
<li><b>${PULL_REQUEST_FROM_SSH_CLONE_URL}</b> Example: ssh://git@localhost:7999/project_1/rep_1</li>
6263
<li><b>${PULL_REQUEST_FROM_HTTP_CLONE_URL}</b> Example: http://admin@localhost:7990/stash/scm/project_1/rep_1.git</li>
6364
<li><b>${PULL_REQUEST_FROM_HASH}</b> Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad</li>

0 commit comments

Comments
 (0)