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

Commit d04d4bb

Browse files
committed
Hash of merged commit (only available for merged-event) #75
1 parent 65c035a commit d04d4bb

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
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 Bitbucket.
44

5+
## 2.8
6+
* New variables
7+
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
8+
59
## 2.7
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
@@ -60,6 +60,7 @@ The filter text as well as the URL support variables. These are:
6060
* ${PULL_REQUEST_AUTHOR_SLUG} Example: admin
6161
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
6262
* ${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT} Number of participants that approved the PR.
63+
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
6364
* ${PULL_REQUEST_FROM_SSH_CLONE_URL} Example: ssh://git@localhost:7999/project_1/rep_1
6465
* ${PULL_REQUEST_FROM_HTTP_CLONE_URL} Example: http://admin@localhost:7990/bitbucket/scm/project_1/rep_1.git
6566
* ${PULL_REQUEST_FROM_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import static se.bjurr.prnfb.admin.AdminFormValues.TRIGGER_IF_MERGE.NOT_CONFLICTING;
1414
import static se.bjurr.prnfb.listener.PrnfbPullRequestAction.fromPullRequestEvent;
1515
import static se.bjurr.prnfb.listener.PrnfbRenderer.PrnfbVariable.PULL_REQUEST_COMMENT_TEXT;
16+
import static se.bjurr.prnfb.listener.PrnfbRenderer.PrnfbVariable.PULL_REQUEST_MERGE_COMMIT;
1617
import static se.bjurr.prnfb.listener.UrlInvoker.urlInvoker;
1718
import static se.bjurr.prnfb.settings.SettingsStorage.getPrnfbSettings;
1819

@@ -133,6 +134,13 @@ public void handleEvent(final PullRequestEvent pullRequestEvent) {
133134
if (pullRequestEvent instanceof PullRequestCommentAddedEvent) {
134135
variables.put(PULL_REQUEST_COMMENT_TEXT, () -> ((PullRequestCommentAddedEvent) pullRequestEvent).getComment()
135136
.getText());
137+
} else if (pullRequestEvent instanceof PullRequestMergedEvent) {
138+
variables.put(PULL_REQUEST_MERGE_COMMIT, new Supplier<String>() {
139+
@Override
140+
public String get() {
141+
return ((PullRequestMergedEvent) pullRequestEvent).getCommit().getId();
142+
}
143+
});
136144
}
137145
PrnfbRenderer renderer = new PrnfbRenderer(pullRequestEvent.getPullRequest(), action, pullRequestEvent.getUser(),
138146
repositoryService, propertiesService, notification, variables);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfbPullR
287287
Map<PrnfbRenderer.PrnfbVariable, Supplier<String>> variables) {
288288
return getOrEmpty(variables, PULL_REQUEST_COMMENT_TEXT);
289289
}
290+
}), PULL_REQUEST_MERGE_COMMIT(new Resolver() {
291+
@Override
292+
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfsPullRequestAction,
293+
ApplicationUser stashUser, RepositoryService repositoryService, ApplicationPropertiesService propertiesService,
294+
PrnfbNotification prnfsNotification, Map<PrnfbRenderer.PrnfbVariable, Supplier<String>> variables) {
295+
return getOrEmpty(variables, PULL_REQUEST_MERGE_COMMIT);
296+
}
290297
}), PULL_REQUEST_USER_DISPLAY_NAME(new Resolver() {
291298
@Override
292299
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfbPullRequestAction,

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/bitbucket/scm/project_1/rep_1.git</li>
6364
<li><b>${PULL_REQUEST_FROM_HASH}</b> Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad</li>

0 commit comments

Comments
 (0)