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

Commit

Permalink
Variables to display names of approved, unapproved and needs work #192
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Feb 2, 2017
1 parent 7654610 commit dba06db
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
Changelog of Pull Request Notifier for Bitbucket.

## Unreleased
### GitHub [#192](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/192) Include status for participants
Variables to display names of approved, unapproved and needs work

[5417db3500e869c](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/5417db3500e869c) Tomas Bjerre *2017-02-02 16:48:45*

### No issue
doc

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

## 2.51
### GitHub [#191](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/191) Notification for "Needs Work"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ The filter text as well as the URL support variables. These are:
| `${PULL_REQUEST_REVIEWERS_APPROVED_SLUG}` | Example: admin,user. |
| `${PULL_REQUEST_REVIEWERS_APPROVED_EMAIL}` | Example: [email protected],[email protected]. |
| `${PULL_REQUEST_REVIEWERS_APPROVED_NAME}` | Example: Admin,User. |
| `${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT}` | Number of reviewers that unapproved the PR. |
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG}` | Example: admin,user. |
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL}` | Example: [email protected],[email protected]. |
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME}` | Example: Admin,User. |
| `${PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT}` | Number of reviewers that says the PR needs work. |
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG}` | Example: admin,user. |
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL}` | Example: [email protected],[email protected]. |
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME}` | Example: Admin,User. |
| `${PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME}` | Example: Admin Adminson,User Userson. |
| `${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}` | Number of participants that approved the PR. |
| `${PULL_REQUEST_PARTICIPANTS_EMAIL}` | Example: `[email protected],[email protected]` |
| `${PULL_REQUEST_MERGE_COMMIT}` | Hash of merged commit (only available for merged-event). |
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,25 @@ public String resolve(
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
}
}),
PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME(
new PrnfbVariableResolver() {
@Override
public String resolve(
PullRequest pullRequest,
PrnfbPullRequestAction pullRequestAction,
ApplicationUser applicationUser,
RepositoryService repositoryService,
ApplicationPropertiesService propertiesService,
PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables,
ClientKeyStore clientKeyStore,
boolean shouldAcceptAnyCertificate,
SecurityService securityService) {
Iterable<PullRequestParticipant> reviewers =
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == NEEDS_WORK);
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
}
}),
PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG(
new PrnfbVariableResolver() {
@Override
Expand Down Expand Up @@ -697,6 +716,25 @@ public String resolve(
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
}
}),
PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME(
new PrnfbVariableResolver() {
@Override
public String resolve(
PullRequest pullRequest,
PrnfbPullRequestAction pullRequestAction,
ApplicationUser applicationUser,
RepositoryService repositoryService,
ApplicationPropertiesService propertiesService,
PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables,
ClientKeyStore clientKeyStore,
boolean shouldAcceptAnyCertificate,
SecurityService securityService) {
Iterable<PullRequestParticipant> reviewers =
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == UNAPPROVED);
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
}
}),
PULL_REQUEST_REVIEWERS_APPROVED_SLUG(
new PrnfbVariableResolver() {
@Override
Expand Down Expand Up @@ -754,6 +792,25 @@ public String resolve(
return iterableToString(transform(reviewers, (p) -> p.getUser().getName()));
}
}),
PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME(
new PrnfbVariableResolver() {
@Override
public String resolve(
PullRequest pullRequest,
PrnfbPullRequestAction pullRequestAction,
ApplicationUser applicationUser,
RepositoryService repositoryService,
ApplicationPropertiesService propertiesService,
PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables,
ClientKeyStore clientKeyStore,
boolean shouldAcceptAnyCertificate,
SecurityService securityService) {
Iterable<PullRequestParticipant> reviewers =
filter(pullRequest.getReviewers(), (r) -> r.getStatus() == APPROVED);
return iterableToString(transform(reviewers, (p) -> p.getUser().getDisplayName()));
}
}),
PULL_REQUEST_REVIEWERS_ID(
new PrnfbVariableResolver() {
@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_SLUG}</b> Example: admin,user.</li>
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_EMAIL}</b> Example: [email protected],[email protected].</li>
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_NAME}</b> Example: Admin,User.</li>
<li><b>${PULL_REQUEST_REVIEWERS_APPROVED_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_COUNT}</b> Number of reviewers that unapproved the PR.</li>
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_SLUG}</b> Example: admin,user.</li>
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_EMAIL}</b> Example: [email protected],[email protected].</li>
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_NAME}</b> Example: Admin,User.</li>
<li><b>${PULL_REQUEST_REVIEWERS_UNAPPROVED_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_COUNT}</b> Number of reviewers that says the PR needs work.</li>
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_SLUG}</b> Example: admin,user.</li>
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL}</b> Example: [email protected],[email protected].</li>
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME}</b> Example: Admin,User.</li>
<li><b>${PULL_REQUEST_REVIEWERS_NEEDS_WORK_DISPLAY_NAME}</b> Example: Admin Adminson,User Userson.</li>
<li><b>${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}</b> Number of participants that approved the PR.</li>
<li><b>${PULL_REQUEST_PARTICIPANTS_EMAIL}</b> Example: [email protected],[email protected].</li>
<li><b>${PULL_REQUEST_MERGE_COMMIT}</b> Hash of merged commit (only available for merged-event).</li>
Expand Down

0 comments on commit dba06db

Please sign in to comment.