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

Commit 66533c8

Browse files
committed
Merge pull request #94 from zhang6464/master
Adding variables: * ${PULL_REQUEST_REVIEWERS} Example: Administrator,User * ${PULL_REQUEST_REVIEWERS_ID} Example: 1,2 * ${PULL_REQUEST_REVIEWERS_SLUG} Example: admin,use
2 parents c56ce0a + 60732c8 commit 66533c8

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog of Pull Request Notifier for Bitbucket.
55
## 2.13
66
* Allowing SSL certificates to be ignored.
77
* Adding settings to configure custom keystore.
8+
* Add attribute for list of reviewers, reviewers' IDs and reviewers' names.
89

910
## 2.12
1011
* Fixing PULL_REQUEST_URL-bug correctly with getSlug.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ The filter text as well as the URL support variables. These are:
6060
* ${PULL_REQUEST_AUTHOR_ID} Example: 1
6161
* ${PULL_REQUEST_AUTHOR_NAME} Example: admin
6262
* ${PULL_REQUEST_AUTHOR_SLUG} Example: admin
63+
* ${PULL_REQUEST_REVIEWERS} Example: Administrator,User
64+
* ${PULL_REQUEST_REVIEWERS_ID} Example: 1,2
65+
* ${PULL_REQUEST_REVIEWERS_SLUG} Example: admin,user
6366
* ${PULL_REQUEST_REVIEWERS_APPROVED_COUNT} Number of reviewers that approved the PR.
6467
* ${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT} Number of participants that approved the PR.
6568
* ${PULL_REQUEST_MERGE_COMMIT} Hash of merged commit (only available for merged-event).

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.UnsupportedEncodingException;
1616
import java.util.Map;
1717
import java.util.Set;
18+
import java.util.List;
1819
import java.util.logging.Logger;
1920
import java.util.regex.Matcher;
2021

@@ -440,6 +441,54 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullReques
440441
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
441442
return pullRequest.getTitle();
442443
}
444+
}), PULL_REQUEST_REVIEWERS(new Resolver() {
445+
@Override
446+
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
447+
ApplicationUser applicationUser, RepositoryService repositoryService,
448+
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
449+
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
450+
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
451+
StringBuilder rString = new StringBuilder();
452+
453+
String sep = ",";
454+
for (PullRequestParticipant each : slist) {
455+
rString.append(sep).append(each.getUser().getDisplayName());
456+
}
457+
458+
return rString.substring(1);
459+
}
460+
}), PULL_REQUEST_REVIEWERS_ID(new Resolver() {
461+
@Override
462+
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
463+
ApplicationUser applicationUser, RepositoryService repositoryService,
464+
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
465+
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
466+
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
467+
StringBuilder rString = new StringBuilder();
468+
469+
String sep = ",";
470+
for (PullRequestParticipant each : slist) {
471+
rString.append(sep).append(Integer.toString(each.getUser().getId()));
472+
}
473+
474+
return rString.substring(1);
475+
}
476+
}), PULL_REQUEST_REVIEWERS_SLUG(new Resolver() {
477+
@Override
478+
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
479+
ApplicationUser applicationUser, RepositoryService repositoryService,
480+
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
481+
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
482+
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
483+
StringBuilder rString = new StringBuilder();
484+
485+
String sep = ",";
486+
for (PullRequestParticipant each : slist) {
487+
rString.append(sep).append(each.getUser().getSlug());
488+
}
489+
490+
return rString.substring(1);
491+
}
443492
}), PULL_REQUEST_REVIEWERS_APPROVED_COUNT(new Resolver() {
444493
@Override
445494
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,

src/main/resources/admin.vm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
<div class="prnfb-BUTTON_CONFIG_FORM">
4949
</div>
50-
50+
5151
<div>
5252
<div class="description">
5353
You can use variables when invoking the URL, when forming the filter string, custom header values or in POST content.
@@ -70,6 +70,9 @@
7070
<li><b>${PULL_REQUEST_AUTHOR_ID}</b> Example: 1</li>
7171
<li><b>${PULL_REQUEST_AUTHOR_NAME}</b> Example: admin</li>
7272
<li><b>${PULL_REQUEST_AUTHOR_SLUG}</b> Example: admin</li>
73+
<li><b>${PULL_REQUEST_REVIEWERS}</b> Reviewers list.</li>
74+
<li><b>${PULL_REQUEST_REVIEWERS_ID}</b> Reviewers ID list.</li>
75+
<li><b>${PULL_REQUEST_REVIEWERS_SLUG}</b> Reviewers slug list.</li>
7376
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}</b> Number of reviewers that approved the PR.</li>
7477
<li><b>${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}</b> Number of participants that approved the PR.</li>
7578
<li><b>${PULL_REQUEST_MERGE_COMMIT}</b> Hash of merged commit (only available for merged-event).</li>
@@ -96,10 +99,10 @@
9699
</ul>
97100
</div>
98101
</div>
99-
102+
100103
<div class="prnfb-TRIGGER_CONFIG_FORM">
101104
</div>
102-
105+
103106
<div class="prnfb-template prnfb-template-BUTTON_CONFIG_FORM">
104107
<form class="config-area">
105108
<div class="content">
@@ -133,7 +136,7 @@
133136
</div>
134137
</form>
135138
</div>
136-
139+
137140
<div class="prnfb-template prnfb-template-TRIGGER_CONFIG_FORM">
138141
<form class="trigger config-area">
139142
<div class="expandable">

0 commit comments

Comments
 (0)