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

Commit c19f72f

Browse files
committed
Fixing PULL_REQUEST_URL-bug correctly with getSlug #82
1 parent 0cd2c14 commit c19f72f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Changelog of Pull Request Notifier for Bitbucket.
44

5+
## 2.12
6+
* Fixing PULL_REQUEST_URL-bug correctly with getSlug.
7+
58
## 2.11
69
* Bugfix: Replacing spaces with dashes in ${PULL_REQUEST_URL}. Was evaluating to wrong URL if repo name included spaces.
710

src/main/java/se/bjurr/prnfb/listener/PrnfbRenderer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,8 @@ private static String cloneUrlFromRepository(REPO_PROTOCOL protocol, Repository
420420
}
421421

422422
private static String getPullRequestUrl(ApplicationPropertiesService propertiesService, PullRequest pullRequest) {
423-
return (propertiesService.getBaseUrl() + "/projects/" + pullRequest.getToRef().getRepository().getProject().getKey()
424-
+ "/repos/" + pullRequest.getToRef().getRepository().getName() + "/pull-requests/" + pullRequest.getId())
425-
.replaceAll(" ", "-");
423+
return propertiesService.getBaseUrl() + "/projects/" + pullRequest.getToRef().getRepository().getProject().getKey()
424+
+ "/repos/" + pullRequest.getToRef().getRepository().getSlug() + "/pull-requests/" + pullRequest.getId();
426425
}
427426

428427
PrnfbVariable(Resolver resolver) {

src/test/java/se/bjurr/prnfb/admin/PrnfbPullRequestEventListenerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public void testThatAUrlWithVariablesExceptFromAndToCanBeInvoked() throws Except
411411
pullRequestRefBuilder() //
412412
.withProjectKey("theProject") //
413413
.withRepositoryName("the Repo Name") //
414-
) //
414+
.withRepositorySlug("the-repo-name")) //
415415
.withPullRequestAction(OPENED) //
416416
.withAuthor( //
417417
prnfbParticipantBuilder() //
@@ -426,7 +426,7 @@ public void testThatAUrlWithVariablesExceptFromAndToCanBeInvoked() throws Except
426426
) //
427427
.invokedUrl(
428428
0,
429-
"http://bjurr.se/id=10&action=OPENED&displayName=authorDisplayName&authorEmail=authorEmail&authorId=100&authorName=authorName&authorSlug=authorSlug&pullRequestUrl=http%3A%2F%2Fbitbucket.server%2Fprojects%2FtheProject%2Frepos%2Fthe-Repo-Name%2Fpull-requests%2F10" //
429+
"http://bjurr.se/id=10&action=OPENED&displayName=authorDisplayName&authorEmail=authorEmail&authorId=100&authorName=authorName&authorSlug=authorSlug&pullRequestUrl=http%3A%2F%2Fbitbucket.server%2Fprojects%2FtheProject%2Frepos%2Fthe-repo-name%2Fpull-requests%2F10" //
430430
);
431431
}
432432

0 commit comments

Comments
 (0)