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

Commit

Permalink
update: support reviewers list
Browse files Browse the repository at this point in the history
  • Loading branch information
zhang6464 committed Jan 25, 2016
1 parent c56ce0a commit fcd612e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
49 changes: 49 additions & 0 deletions src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.logging.Logger;
import java.util.regex.Matcher;

Expand Down Expand Up @@ -440,6 +441,54 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullReques
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) {
return pullRequest.getTitle();
}
}), PULL_REQUEST_REVIEWERS(new Resolver() {
@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) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
StringBuilder rString = new StringBuilder();

String sep = ",";
for (PullRequestParticipant each : slist) {
rString.append(sep).append(each.getUser().getDisplayName());
}

return rString.substring(1);
}
}), PULL_REQUEST_REVIEWERS_ID(new Resolver() {
@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) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
StringBuilder rString = new StringBuilder();

String sep = ",";
for (PullRequestParticipant each : slist) {
rString.append(sep).append(Integer.toString(each.getUser().getId()));
}

return rString.substring(1);
}
}), PULL_REQUEST_REVIEWERS_SLUG(new Resolver() {
@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) {
List<PullRequestParticipant> slist = newArrayList(pullRequest.getReviewers());
StringBuilder rString = new StringBuilder();

String sep = ",";
for (PullRequestParticipant each : slist) {
rString.append(sep).append(each.getUser().getSlug());
}

return rString.substring(1);
}
}), PULL_REQUEST_REVIEWERS_APPROVED_COUNT(new Resolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
Expand Down
11 changes: 7 additions & 4 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<div class="prnfb-BUTTON_CONFIG_FORM">
</div>

<div>
<div class="description">
You can use variables when invoking the URL, when forming the filter string, custom header values or in POST content.
Expand All @@ -70,6 +70,9 @@
<li><b>${PULL_REQUEST_AUTHOR_ID}</b> Example: 1</li>
<li><b>${PULL_REQUEST_AUTHOR_NAME}</b> Example: admin</li>
<li><b>${PULL_REQUEST_AUTHOR_SLUG}</b> Example: admin</li>
<li><b>${PULL_REQUEST_REVIEWERS}</b> Reviewers list.</li>
<li><b>${PULL_REQUEST_REVIEWERS_ID}</b> Reviewers ID list.</li>
<li><b>${PULL_REQUEST_REVIEWERS_SLUG}</b> Reviewers slug list.</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>
Expand All @@ -96,10 +99,10 @@
</ul>
</div>
</div>

<div class="prnfb-TRIGGER_CONFIG_FORM">
</div>

<div class="prnfb-template prnfb-template-BUTTON_CONFIG_FORM">
<form class="config-area">
<div class="content">
Expand Down Expand Up @@ -133,7 +136,7 @@
</div>
</form>
</div>

<div class="prnfb-template prnfb-template-TRIGGER_CONFIG_FORM">
<form class="trigger config-area">
<div class="expandable">
Expand Down

0 comments on commit fcd612e

Please sign in to comment.