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

Commit dba06db

Browse files
committed
Variables to display names of approved, unapproved and needs work #192
1 parent 7654610 commit dba06db

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
Changelog of Pull Request Notifier for Bitbucket.
44

55
## Unreleased
6+
### GitHub [#192](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/192) Include status for participants
7+
Variables to display names of approved, unapproved and needs work
8+
9+
[5417db3500e869c](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/5417db3500e869c) Tomas Bjerre *2017-02-02 16:48:45*
10+
611
### No issue
712
doc
813

9-
[a3b9329a1651226](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/a3b9329a1651226) Tomas Bjerre *2017-02-01 19:51:14*
14+
[7654610bc8ecd9a](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/7654610bc8ecd9a) Tomas Bjerre *2017-02-01 19:51:51*
1015

1116
## 2.51
1217
### GitHub [#191](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/191) Notification for "Needs Work"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,17 @@ The filter text as well as the URL support variables. These are:
8080
| `${PULL_REQUEST_REVIEWERS_APPROVED_SLUG}` | Example: admin,user. |
8181
| `${PULL_REQUEST_REVIEWERS_APPROVED_EMAIL}` | Example: admin@example.com,user@example.com. |
8282
| `${PULL_REQUEST_REVIEWERS_APPROVED_NAME}` | Example: Admin,User. |
83+
| `${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
8384
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT}` | Number of reviewers that unapproved the PR. |
8485
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG}` | Example: admin,user. |
8586
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL}` | Example: admin@example.com,user@example.com. |
8687
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME}` | Example: Admin,User. |
88+
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
8789
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT}` | Number of reviewers that says the PR needs work. |
8890
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG}` | Example: admin,user. |
8991
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL}` | Example: admin@example.com,user@example.com. |
9092
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME}` | Example: Admin,User. |
93+
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
9194
| `${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}` | Number of participants that approved the PR. |
9295
| `${PULL_REQUEST_PARTICIPANTS_EMAIL}` | Example: `admin@example.com,user@example.com` |
9396
| `${PULL_REQUEST_MERGE_COMMIT}` | Hash of merged commit (only available for merged-event). |

src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,25 @@ public String resolve(
640640
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
641641
}
642642
}),
643+
PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME(
644+
new PrnfbVariableResolver() {
645+
@Override
646+
public String resolve(
647+
PullRequest pullRequest,
648+
PrnfbPullRequestAction pullRequestAction,
649+
ApplicationUser applicationUser,
650+
RepositoryService repositoryService,
651+
ApplicationPropertiesService propertiesService,
652+
PrnfbNotification prnfbNotification,
653+
Map<PrnfbVariable, Supplier<String>> variables,
654+
ClientKeyStore clientKeyStore,
655+
boolean shouldAcceptAnyCertificate,
656+
SecurityService securityService) {
657+
Iterable<PullRequestParticipant> reviewers =
658+
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == NEEDS_WORK);
659+
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
660+
}
661+
}),
643662
PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG(
644663
new PrnfbVariableResolver() {
645664
@Override
@@ -697,6 +716,25 @@ public String resolve(
697716
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
698717
}
699718
}),
719+
PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME(
720+
new PrnfbVariableResolver() {
721+
@Override
722+
public String resolve(
723+
PullRequest pullRequest,
724+
PrnfbPullRequestAction pullRequestAction,
725+
ApplicationUser applicationUser,
726+
RepositoryService repositoryService,
727+
ApplicationPropertiesService propertiesService,
728+
PrnfbNotification prnfbNotification,
729+
Map<PrnfbVariable, Supplier<String>> variables,
730+
ClientKeyStore clientKeyStore,
731+
boolean shouldAcceptAnyCertificate,
732+
SecurityService securityService) {
733+
Iterable<PullRequestParticipant> reviewers =
734+
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == UNAPPROVED);
735+
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
736+
}
737+
}),
700738
PULL_REQUEST_REVIEWERS_APPROVED_SLUG(
701739
new PrnfbVariableResolver() {
702740
@Override
@@ -754,6 +792,25 @@ public String resolve(
754792
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
755793
}
756794
}),
795+
PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME(
796+
new PrnfbVariableResolver() {
797+
@Override
798+
public String resolve(
799+
PullRequest pullRequest,
800+
PrnfbPullRequestAction pullRequestAction,
801+
ApplicationUser applicationUser,
802+
RepositoryService repositoryService,
803+
ApplicationPropertiesService propertiesService,
804+
PrnfbNotification prnfbNotification,
805+
Map<PrnfbVariable, Supplier<String>> variables,
806+
ClientKeyStore clientKeyStore,
807+
boolean shouldAcceptAnyCertificate,
808+
SecurityService securityService) {
809+
Iterable<PullRequestParticipant> reviewers =
810+
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == APPROVED);
811+
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
812+
}
813+
}),
757814
PULL_REQUEST_REVIEWERS_ID(
758815
new PrnfbVariableResolver() {
759816
@Override

src/main/resources/admin.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@
7979
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_SLUG}</b> Example: admin,user.</li>
8080
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_EMAIL}</b> Example: admin@example.com,user@example.com.</li>
8181
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_NAME}</b> Example: Admin,User.</li>
82+
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
8283
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT}</b> Number of reviewers that unapproved the PR.</li>
8384
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG}</b> Example: admin,user.</li>
8485
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL}</b> Example: admin@example.com,user@example.com.</li>
8586
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME}</b> Example: Admin,User.</li>
87+
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
8688
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT}</b> Number of reviewers that says the PR needs work.</li>
8789
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG}</b> Example: admin,user.</li>
8890
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL}</b> Example: admin@example.com,user@example.com.</li>
8991
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME}</b> Example: Admin,User.</li>
92+
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
9093
<li><b>${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}</b> Number of participants that approved the PR.</li>
9194
<li><b>${PULL_REQUEST_PARTICIPANTS_EMAIL}</b> Example: admin@example.com,user@example.com.</li>
9295
<li><b>${PULL_REQUEST_MERGE_COMMIT}</b> Hash of merged commit (only available for merged-event).</li>

0 commit comments

Comments
 (0)