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

Commit

Permalink
Hash of merged commit (only available for merged-event) #75
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Oct 14, 2015
1 parent 65c035a commit d04d4bb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Changelog of Pull Request Notifier for Bitbucket.

## 2.8
* New variables
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).

## 2.7
* New variables
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The filter text as well as the URL support variables. These are:
* ${PULL_REQUEST_AUTHOR_SLUG} Example: admin
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
* ${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT} Number of participants that approved the PR.
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).
* ${PULL_REQUEST_FROM_SSH_CLONE_URL} Example: ssh://git@localhost:7999/project_1/rep_1
* ${PULL_REQUEST_FROM_HTTP_CLONE_URL} Example: http://admin@localhost:7990/bitbucket/scm/project_1/rep_1.git
* ${PULL_REQUEST_FROM_HASH} Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static se.bjurr.prnfb.admin.AdminFormValues.TRIGGER_IF_MERGE.NOT_CONFLICTING;
import static se.bjurr.prnfb.listener.PrnfbPullRequestAction.fromPullRequestEvent;
import static se.bjurr.prnfb.listener.PrnfbRenderer.PrnfbVariable.PULL_REQUEST_COMMENT_TEXT;
import static se.bjurr.prnfb.listener.PrnfbRenderer.PrnfbVariable.PULL_REQUEST_MERGE_COMMIT;
import static se.bjurr.prnfb.listener.UrlInvoker.urlInvoker;
import static se.bjurr.prnfb.settings.SettingsStorage.getPrnfbSettings;

Expand Down Expand Up @@ -133,6 +134,13 @@ public void handleEvent(final PullRequestEvent pullRequestEvent) {
if (pullRequestEvent instanceof PullRequestCommentAddedEvent) {
variables.put(PULL_REQUEST_COMMENT_TEXT, () -> ((PullRequestCommentAddedEvent) pullRequestEvent).getComment()
.getText());
} else if (pullRequestEvent instanceof PullRequestMergedEvent) {
variables.put(PULL_REQUEST_MERGE_COMMIT, new Supplier<String>() {
@Override
public String get() {
return ((PullRequestMergedEvent) pullRequestEvent).getCommit().getId();
}
});
}
PrnfbRenderer renderer = new PrnfbRenderer(pullRequestEvent.getPullRequest(), action, pullRequestEvent.getUser(),
repositoryService, propertiesService, notification, variables);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfbPullR
Map<PrnfbRenderer.PrnfbVariable, Supplier<String>> variables) {
return getOrEmpty(variables, PULL_REQUEST_COMMENT_TEXT);
}
}), PULL_REQUEST_MERGE_COMMIT(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfsPullRequestAction,
ApplicationUser stashUser, RepositoryService repositoryService, ApplicationPropertiesService propertiesService,
PrnfbNotification prnfsNotification, Map<PrnfbRenderer.PrnfbVariable, Supplier<String>> variables) {
return getOrEmpty(variables, PULL_REQUEST_MERGE_COMMIT);
}
}), PULL_REQUEST_USER_DISPLAY_NAME(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfbPullRequestAction,
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<li><b>${PULL_REQUEST_AUTHOR_SLUG}</b> Example: admin</li>
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}</b> Number of reviewers that approved the PR.</li>
<li><b>${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}</b> Number of participants that approved the PR.</li>
<li><b>${PULL_REQUEST_MERGE_COMMIT}</b> Hash of merged commit (only available for merged-event).</li>
<li><b>${PULL_REQUEST_FROM_SSH_CLONE_URL}</b> Example: ssh://git@localhost:7999/project_1/rep_1</li>
<li><b>${PULL_REQUEST_FROM_HTTP_CLONE_URL}</b> Example: http://admin@localhost:7990/bitbucket/scm/project_1/rep_1.git</li>
<li><b>${PULL_REQUEST_FROM_HASH}</b> Example: 6053a1eaa1c009dd11092d09a72f3c41af1b59ad</li>
Expand Down

0 comments on commit d04d4bb

Please sign in to comment.