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

Commit

Permalink
Adding PULL_REQUEST_STATE variable #137
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Jul 30, 2016
1 parent f303ecd commit 2455b33
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Changelog of Pull Request Notifier for Bitbucket.

## Unreleased
### GitHub [#137](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/137) Triigger build button appears in the merged PR view too.
Adding PULL_REQUEST_STATE variable

[064030fe3420fe0](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/064030fe3420fe0) Tomas Bjerre *2016-07-30 08:48:07*

## 2.33
### GitHub [#134](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/134) Not able to see PR buttons
Checking privilegies for both project and repo

Expand All @@ -18,7 +24,7 @@ Changelog of Pull Request Notifier for Bitbucket.
### No issue
Correcting conformation value when buttons pressed

[bab535e5bc6e3d6](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/bab535e5bc6e3d6) Tomas Bjerre *2016-07-30 08:19:22*
[5b60ace015f6128](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/5b60ace015f6128) Tomas Bjerre *2016-07-30 08:34:08*

Filtering buttons in buttons resource, and filtering out allowed buttons

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The filter text as well as the URL support variables. These are:
* ${PULL_REQUEST_VERSION} Example: 1
* ${PULL_REQUEST_COMMENT_TEXT} Example: A comment
* ${PULL_REQUEST_ACTION} Example: OPENED
* ${PULL_REQUEST_STATE} Example: DECLINED, MERGED, OPEN
* ${BUTTON_TRIGGER_TITLE} Example: Trigger Notification
* ${INJECTION_URL_VALUE} Value retrieved from any URL
* ${PULL_REQUEST_URL} Example: http://localhost:7990/projects/PROJECT_1/repos/rep_1/pull-requests/1
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullReques
return iterableToString(transform(pullRequest.getReviewers(), (p) -> p.getUser().getSlug()));
}

}), PULL_REQUEST_STATE(new PrnfbVariableResolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction prnfbPullRequestAction,
ApplicationUser applicationUser, RepositoryService repositoryService,
ApplicationPropertiesService propertiesService, PrnfbNotification prnfbNotification,
Map<PrnfbVariable, Supplier<String>> variables, ClientKeyStore clientKeyStore, boolean shouldAcceptAnyCertificate,
SecurityService securityService) {
return pullRequest.getState().name();
}
}), PULL_REQUEST_TITLE(new PrnfbVariableResolver() {
@Override
public String resolve(PullRequest pullRequest, PrnfbPullRequestAction pullRequestAction,
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/admin.vm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<li><b>${PULL_REQUEST_ID}</b> Example: 1</li>
<li><b>${PULL_REQUEST_TITLE}</b> Example: Anything</li>
<li><b>${PULL_REQUEST_ACTION}</b> Example: OPENED</li>
<li><b>${PULL_REQUEST_STATE}</b> Example: DECLINED, MERGED, OPEN</li>
<li><b>${PULL_REQUEST_URL}</b> Example: http://localhost:7990/projects/PROJECT_1/repos/rep_1/pull-requests/1</li>
<li><b>${PULL_REQUEST_VERSION}</b> Example: 1</li>
<li><b>${PULL_REQUEST_COMMENT_TEXT}</b> Example: A comment</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void testThatEverythingCanBeRendered() throws UnsupportedEncodingExceptio

assertThat(actual)//
.isEqualTo(
"asd BUTTON_TRIGGER_TITLE=${BUTTON_TRIGGER_TITLE}&INJECTION_URL_VALUE=${INJECTION_URL_VALUE}&PULL_REQUEST_ACTION=${PULL_REQUEST_ACTION}&PULL_REQUEST_AUTHOR_DISPLAY_NAME=${PULL_REQUEST_AUTHOR_DISPLAY_NAME}&PULL_REQUEST_AUTHOR_EMAIL=${PULL_REQUEST_AUTHOR_EMAIL}&PULL_REQUEST_AUTHOR_ID=${PULL_REQUEST_AUTHOR_ID}&PULL_REQUEST_AUTHOR_NAME=${PULL_REQUEST_AUTHOR_NAME}&PULL_REQUEST_AUTHOR_SLUG=${PULL_REQUEST_AUTHOR_SLUG}&PULL_REQUEST_COMMENT_TEXT=${PULL_REQUEST_COMMENT_TEXT}&PULL_REQUEST_FROM_BRANCH=${PULL_REQUEST_FROM_BRANCH}&PULL_REQUEST_FROM_HASH=${PULL_REQUEST_FROM_HASH}&PULL_REQUEST_FROM_HTTP_CLONE_URL=${PULL_REQUEST_FROM_HTTP_CLONE_URL}&PULL_REQUEST_FROM_ID=${PULL_REQUEST_FROM_ID}&PULL_REQUEST_FROM_REPO_ID=${PULL_REQUEST_FROM_REPO_ID}&PULL_REQUEST_FROM_REPO_NAME=${PULL_REQUEST_FROM_REPO_NAME}&PULL_REQUEST_FROM_REPO_PROJECT_ID=${PULL_REQUEST_FROM_REPO_PROJECT_ID}&PULL_REQUEST_FROM_REPO_PROJECT_KEY=${PULL_REQUEST_FROM_REPO_PROJECT_KEY}&PULL_REQUEST_FROM_REPO_SLUG=${PULL_REQUEST_FROM_REPO_SLUG}&PULL_REQUEST_FROM_SSH_CLONE_URL=${PULL_REQUEST_FROM_SSH_CLONE_URL}&PULL_REQUEST_ID=${PULL_REQUEST_ID}&PULL_REQUEST_MERGE_COMMIT=${PULL_REQUEST_MERGE_COMMIT}&PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT=${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS=${PULL_REQUEST_REVIEWERS}&PULL_REQUEST_REVIEWERS_APPROVED_COUNT=${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS_ID=${PULL_REQUEST_REVIEWERS_ID}&PULL_REQUEST_REVIEWERS_SLUG=${PULL_REQUEST_REVIEWERS_SLUG}&PULL_REQUEST_TITLE=${PULL_REQUEST_TITLE}&PULL_REQUEST_TO_BRANCH=${PULL_REQUEST_TO_BRANCH}&PULL_REQUEST_TO_HASH=${PULL_REQUEST_TO_HASH}&PULL_REQUEST_TO_HTTP_CLONE_URL=${PULL_REQUEST_TO_HTTP_CLONE_URL}&PULL_REQUEST_TO_ID=${PULL_REQUEST_TO_ID}&PULL_REQUEST_TO_REPO_ID=${PULL_REQUEST_TO_REPO_ID}&PULL_REQUEST_TO_REPO_NAME=${PULL_REQUEST_TO_REPO_NAME}&PULL_REQUEST_TO_REPO_PROJECT_ID=${PULL_REQUEST_TO_REPO_PROJECT_ID}&PULL_REQUEST_TO_REPO_PROJECT_KEY=${PULL_REQUEST_TO_REPO_PROJECT_KEY}&PULL_REQUEST_TO_REPO_SLUG=${PULL_REQUEST_TO_REPO_SLUG}&PULL_REQUEST_TO_SSH_CLONE_URL=${PULL_REQUEST_TO_SSH_CLONE_URL}&PULL_REQUEST_URL=${PULL_REQUEST_URL}&PULL_REQUEST_USER_DISPLAY_NAME=${PULL_REQUEST_USER_DISPLAY_NAME}&PULL_REQUEST_USER_EMAIL_ADDRESS=${PULL_REQUEST_USER_EMAIL_ADDRESS}&PULL_REQUEST_USER_ID=${PULL_REQUEST_USER_ID}&PULL_REQUEST_USER_NAME=${PULL_REQUEST_USER_NAME}&PULL_REQUEST_USER_SLUG=${PULL_REQUEST_USER_SLUG}&PULL_REQUEST_VERSION=${PULL_REQUEST_VERSION} asd");
"asd BUTTON_TRIGGER_TITLE=${BUTTON_TRIGGER_TITLE}&INJECTION_URL_VALUE=${INJECTION_URL_VALUE}&PULL_REQUEST_ACTION=${PULL_REQUEST_ACTION}&PULL_REQUEST_AUTHOR_DISPLAY_NAME=${PULL_REQUEST_AUTHOR_DISPLAY_NAME}&PULL_REQUEST_AUTHOR_EMAIL=${PULL_REQUEST_AUTHOR_EMAIL}&PULL_REQUEST_AUTHOR_ID=${PULL_REQUEST_AUTHOR_ID}&PULL_REQUEST_AUTHOR_NAME=${PULL_REQUEST_AUTHOR_NAME}&PULL_REQUEST_AUTHOR_SLUG=${PULL_REQUEST_AUTHOR_SLUG}&PULL_REQUEST_COMMENT_TEXT=${PULL_REQUEST_COMMENT_TEXT}&PULL_REQUEST_FROM_BRANCH=${PULL_REQUEST_FROM_BRANCH}&PULL_REQUEST_FROM_HASH=${PULL_REQUEST_FROM_HASH}&PULL_REQUEST_FROM_HTTP_CLONE_URL=${PULL_REQUEST_FROM_HTTP_CLONE_URL}&PULL_REQUEST_FROM_ID=${PULL_REQUEST_FROM_ID}&PULL_REQUEST_FROM_REPO_ID=${PULL_REQUEST_FROM_REPO_ID}&PULL_REQUEST_FROM_REPO_NAME=${PULL_REQUEST_FROM_REPO_NAME}&PULL_REQUEST_FROM_REPO_PROJECT_ID=${PULL_REQUEST_FROM_REPO_PROJECT_ID}&PULL_REQUEST_FROM_REPO_PROJECT_KEY=${PULL_REQUEST_FROM_REPO_PROJECT_KEY}&PULL_REQUEST_FROM_REPO_SLUG=${PULL_REQUEST_FROM_REPO_SLUG}&PULL_REQUEST_FROM_SSH_CLONE_URL=${PULL_REQUEST_FROM_SSH_CLONE_URL}&PULL_REQUEST_ID=${PULL_REQUEST_ID}&PULL_REQUEST_MERGE_COMMIT=${PULL_REQUEST_MERGE_COMMIT}&PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT=${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS=${PULL_REQUEST_REVIEWERS}&PULL_REQUEST_REVIEWERS_APPROVED_COUNT=${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS_ID=${PULL_REQUEST_REVIEWERS_ID}&PULL_REQUEST_REVIEWERS_SLUG=${PULL_REQUEST_REVIEWERS_SLUG}&PULL_REQUEST_STATE=${PULL_REQUEST_STATE}&PULL_REQUEST_TITLE=${PULL_REQUEST_TITLE}&PULL_REQUEST_TO_BRANCH=${PULL_REQUEST_TO_BRANCH}&PULL_REQUEST_TO_HASH=${PULL_REQUEST_TO_HASH}&PULL_REQUEST_TO_HTTP_CLONE_URL=${PULL_REQUEST_TO_HTTP_CLONE_URL}&PULL_REQUEST_TO_ID=${PULL_REQUEST_TO_ID}&PULL_REQUEST_TO_REPO_ID=${PULL_REQUEST_TO_REPO_ID}&PULL_REQUEST_TO_REPO_NAME=${PULL_REQUEST_TO_REPO_NAME}&PULL_REQUEST_TO_REPO_PROJECT_ID=${PULL_REQUEST_TO_REPO_PROJECT_ID}&PULL_REQUEST_TO_REPO_PROJECT_KEY=${PULL_REQUEST_TO_REPO_PROJECT_KEY}&PULL_REQUEST_TO_REPO_SLUG=${PULL_REQUEST_TO_REPO_SLUG}&PULL_REQUEST_TO_SSH_CLONE_URL=${PULL_REQUEST_TO_SSH_CLONE_URL}&PULL_REQUEST_URL=${PULL_REQUEST_URL}&PULL_REQUEST_USER_DISPLAY_NAME=${PULL_REQUEST_USER_DISPLAY_NAME}&PULL_REQUEST_USER_EMAIL_ADDRESS=${PULL_REQUEST_USER_EMAIL_ADDRESS}&PULL_REQUEST_USER_ID=${PULL_REQUEST_USER_ID}&PULL_REQUEST_USER_NAME=${PULL_REQUEST_USER_NAME}&PULL_REQUEST_USER_SLUG=${PULL_REQUEST_USER_SLUG}&PULL_REQUEST_VERSION=${PULL_REQUEST_VERSION} asd");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testThatEverythingVariableIsResolvedToEveryOtherVariable() {
this.shouldAcceptAnyCertificate, this.securityService);
assertThat(actual)//
.isEqualTo(
"BUTTON_TRIGGER_TITLE=\\${BUTTON_TRIGGER_TITLE}&INJECTION_URL_VALUE=\\${INJECTION_URL_VALUE}&PULL_REQUEST_ACTION=\\${PULL_REQUEST_ACTION}&PULL_REQUEST_AUTHOR_DISPLAY_NAME=\\${PULL_REQUEST_AUTHOR_DISPLAY_NAME}&PULL_REQUEST_AUTHOR_EMAIL=\\${PULL_REQUEST_AUTHOR_EMAIL}&PULL_REQUEST_AUTHOR_ID=\\${PULL_REQUEST_AUTHOR_ID}&PULL_REQUEST_AUTHOR_NAME=\\${PULL_REQUEST_AUTHOR_NAME}&PULL_REQUEST_AUTHOR_SLUG=\\${PULL_REQUEST_AUTHOR_SLUG}&PULL_REQUEST_COMMENT_TEXT=\\${PULL_REQUEST_COMMENT_TEXT}&PULL_REQUEST_FROM_BRANCH=\\${PULL_REQUEST_FROM_BRANCH}&PULL_REQUEST_FROM_HASH=\\${PULL_REQUEST_FROM_HASH}&PULL_REQUEST_FROM_HTTP_CLONE_URL=\\${PULL_REQUEST_FROM_HTTP_CLONE_URL}&PULL_REQUEST_FROM_ID=\\${PULL_REQUEST_FROM_ID}&PULL_REQUEST_FROM_REPO_ID=\\${PULL_REQUEST_FROM_REPO_ID}&PULL_REQUEST_FROM_REPO_NAME=\\${PULL_REQUEST_FROM_REPO_NAME}&PULL_REQUEST_FROM_REPO_PROJECT_ID=\\${PULL_REQUEST_FROM_REPO_PROJECT_ID}&PULL_REQUEST_FROM_REPO_PROJECT_KEY=\\${PULL_REQUEST_FROM_REPO_PROJECT_KEY}&PULL_REQUEST_FROM_REPO_SLUG=\\${PULL_REQUEST_FROM_REPO_SLUG}&PULL_REQUEST_FROM_SSH_CLONE_URL=\\${PULL_REQUEST_FROM_SSH_CLONE_URL}&PULL_REQUEST_ID=\\${PULL_REQUEST_ID}&PULL_REQUEST_MERGE_COMMIT=\\${PULL_REQUEST_MERGE_COMMIT}&PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT=\\${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS=\\${PULL_REQUEST_REVIEWERS}&PULL_REQUEST_REVIEWERS_APPROVED_COUNT=\\${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS_ID=\\${PULL_REQUEST_REVIEWERS_ID}&PULL_REQUEST_REVIEWERS_SLUG=\\${PULL_REQUEST_REVIEWERS_SLUG}&PULL_REQUEST_TITLE=\\${PULL_REQUEST_TITLE}&PULL_REQUEST_TO_BRANCH=\\${PULL_REQUEST_TO_BRANCH}&PULL_REQUEST_TO_HASH=\\${PULL_REQUEST_TO_HASH}&PULL_REQUEST_TO_HTTP_CLONE_URL=\\${PULL_REQUEST_TO_HTTP_CLONE_URL}&PULL_REQUEST_TO_ID=\\${PULL_REQUEST_TO_ID}&PULL_REQUEST_TO_REPO_ID=\\${PULL_REQUEST_TO_REPO_ID}&PULL_REQUEST_TO_REPO_NAME=\\${PULL_REQUEST_TO_REPO_NAME}&PULL_REQUEST_TO_REPO_PROJECT_ID=\\${PULL_REQUEST_TO_REPO_PROJECT_ID}&PULL_REQUEST_TO_REPO_PROJECT_KEY=\\${PULL_REQUEST_TO_REPO_PROJECT_KEY}&PULL_REQUEST_TO_REPO_SLUG=\\${PULL_REQUEST_TO_REPO_SLUG}&PULL_REQUEST_TO_SSH_CLONE_URL=\\${PULL_REQUEST_TO_SSH_CLONE_URL}&PULL_REQUEST_URL=\\${PULL_REQUEST_URL}&PULL_REQUEST_USER_DISPLAY_NAME=\\${PULL_REQUEST_USER_DISPLAY_NAME}&PULL_REQUEST_USER_EMAIL_ADDRESS=\\${PULL_REQUEST_USER_EMAIL_ADDRESS}&PULL_REQUEST_USER_ID=\\${PULL_REQUEST_USER_ID}&PULL_REQUEST_USER_NAME=\\${PULL_REQUEST_USER_NAME}&PULL_REQUEST_USER_SLUG=\\${PULL_REQUEST_USER_SLUG}&PULL_REQUEST_VERSION=\\${PULL_REQUEST_VERSION}")//
"BUTTON_TRIGGER_TITLE=\\${BUTTON_TRIGGER_TITLE}&INJECTION_URL_VALUE=\\${INJECTION_URL_VALUE}&PULL_REQUEST_ACTION=\\${PULL_REQUEST_ACTION}&PULL_REQUEST_AUTHOR_DISPLAY_NAME=\\${PULL_REQUEST_AUTHOR_DISPLAY_NAME}&PULL_REQUEST_AUTHOR_EMAIL=\\${PULL_REQUEST_AUTHOR_EMAIL}&PULL_REQUEST_AUTHOR_ID=\\${PULL_REQUEST_AUTHOR_ID}&PULL_REQUEST_AUTHOR_NAME=\\${PULL_REQUEST_AUTHOR_NAME}&PULL_REQUEST_AUTHOR_SLUG=\\${PULL_REQUEST_AUTHOR_SLUG}&PULL_REQUEST_COMMENT_TEXT=\\${PULL_REQUEST_COMMENT_TEXT}&PULL_REQUEST_FROM_BRANCH=\\${PULL_REQUEST_FROM_BRANCH}&PULL_REQUEST_FROM_HASH=\\${PULL_REQUEST_FROM_HASH}&PULL_REQUEST_FROM_HTTP_CLONE_URL=\\${PULL_REQUEST_FROM_HTTP_CLONE_URL}&PULL_REQUEST_FROM_ID=\\${PULL_REQUEST_FROM_ID}&PULL_REQUEST_FROM_REPO_ID=\\${PULL_REQUEST_FROM_REPO_ID}&PULL_REQUEST_FROM_REPO_NAME=\\${PULL_REQUEST_FROM_REPO_NAME}&PULL_REQUEST_FROM_REPO_PROJECT_ID=\\${PULL_REQUEST_FROM_REPO_PROJECT_ID}&PULL_REQUEST_FROM_REPO_PROJECT_KEY=\\${PULL_REQUEST_FROM_REPO_PROJECT_KEY}&PULL_REQUEST_FROM_REPO_SLUG=\\${PULL_REQUEST_FROM_REPO_SLUG}&PULL_REQUEST_FROM_SSH_CLONE_URL=\\${PULL_REQUEST_FROM_SSH_CLONE_URL}&PULL_REQUEST_ID=\\${PULL_REQUEST_ID}&PULL_REQUEST_MERGE_COMMIT=\\${PULL_REQUEST_MERGE_COMMIT}&PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT=\\${PULL_REQUEST_PARTICIPANTS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS=\\${PULL_REQUEST_REVIEWERS}&PULL_REQUEST_REVIEWERS_APPROVED_COUNT=\\${PULL_REQUEST_REVIEWERS_APPROVED_COUNT}&PULL_REQUEST_REVIEWERS_ID=\\${PULL_REQUEST_REVIEWERS_ID}&PULL_REQUEST_REVIEWERS_SLUG=\\${PULL_REQUEST_REVIEWERS_SLUG}&PULL_REQUEST_STATE=\\${PULL_REQUEST_STATE}&PULL_REQUEST_TITLE=\\${PULL_REQUEST_TITLE}&PULL_REQUEST_TO_BRANCH=\\${PULL_REQUEST_TO_BRANCH}&PULL_REQUEST_TO_HASH=\\${PULL_REQUEST_TO_HASH}&PULL_REQUEST_TO_HTTP_CLONE_URL=\\${PULL_REQUEST_TO_HTTP_CLONE_URL}&PULL_REQUEST_TO_ID=\\${PULL_REQUEST_TO_ID}&PULL_REQUEST_TO_REPO_ID=\\${PULL_REQUEST_TO_REPO_ID}&PULL_REQUEST_TO_REPO_NAME=\\${PULL_REQUEST_TO_REPO_NAME}&PULL_REQUEST_TO_REPO_PROJECT_ID=\\${PULL_REQUEST_TO_REPO_PROJECT_ID}&PULL_REQUEST_TO_REPO_PROJECT_KEY=\\${PULL_REQUEST_TO_REPO_PROJECT_KEY}&PULL_REQUEST_TO_REPO_SLUG=\\${PULL_REQUEST_TO_REPO_SLUG}&PULL_REQUEST_TO_SSH_CLONE_URL=\\${PULL_REQUEST_TO_SSH_CLONE_URL}&PULL_REQUEST_URL=\\${PULL_REQUEST_URL}&PULL_REQUEST_USER_DISPLAY_NAME=\\${PULL_REQUEST_USER_DISPLAY_NAME}&PULL_REQUEST_USER_EMAIL_ADDRESS=\\${PULL_REQUEST_USER_EMAIL_ADDRESS}&PULL_REQUEST_USER_ID=\\${PULL_REQUEST_USER_ID}&PULL_REQUEST_USER_NAME=\\${PULL_REQUEST_USER_NAME}&PULL_REQUEST_USER_SLUG=\\${PULL_REQUEST_USER_SLUG}&PULL_REQUEST_VERSION=\\${PULL_REQUEST_VERSION}")//
.doesNotContain(EVERYTHING_URL.name());
}

Expand Down

0 comments on commit 2455b33

Please sign in to comment.