From fcd612e0d9512a2a8be492a961d2186109af20d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=9B=9F?= Date: Mon, 25 Jan 2016 17:15:49 +0800 Subject: [PATCH] update: support reviewers list --- .../bjurr/prnfb/listener/PrnfbRenderer.java | 49 +++++++++++++++++++ src/main/resources/admin.vm | 11 +++-- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java b/src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java index c5c1dbae..cf092bab 100644 --- a/src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java +++ b/src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java @@ -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; @@ -440,6 +441,54 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullReques Map> 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> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) { + List 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> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) { + List 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> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate) { + List 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, diff --git a/src/main/resources/admin.vm b/src/main/resources/admin.vm index 9877dd7e..af8847aa 100644 --- a/src/main/resources/admin.vm +++ b/src/main/resources/admin.vm @@ -47,7 +47,7 @@
- +
You can use variables when invoking the URL, when forming the filter string, custom header values or in POST content. @@ -70,6 +70,9 @@
  • ${PULL_REQUEST_AUTHOR_ID} Example: 1
  • ${PULL_REQUEST_AUTHOR_NAME} Example: admin
  • ${PULL_REQUEST_AUTHOR_SLUG} Example: admin
  • +
  • ${PULL_REQUEST_REVIEWERS} Reviewers list.
  • +
  • ${PULL_REQUEST_REVIEWERS_ID} Reviewers ID list.
  • +
  • ${PULL_REQUEST_REVIEWERS_SLUG} Reviewers slug list.
  • ${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).
  • @@ -96,10 +99,10 @@
    - +
    - +
    @@ -133,7 +136,7 @@
    - +