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

Commit 1d515f7

Browse files
committed
Fixing PULL_REQUEST_URL-bug correctly with getSlug #82
1 parent d4a3602 commit 1d515f7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
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 Stash.
44

5+
## 1.37
6+
* Fixing PULL_REQUEST_URL-bug correctly with getSlug
7+
58
## 1.36
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/prnfs/listener/PrnfsRenderer.java

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

382382
private static String getPullRequestUrl(ApplicationPropertiesService propertiesService, PullRequest pullRequest) {
383-
return (propertiesService.getBaseUrl() + "/projects/" + pullRequest.getToRef().getRepository().getProject().getKey()
384-
+ "/repos/" + pullRequest.getToRef().getRepository().getName() + "/pull-requests/" + pullRequest.getId())
385-
.replaceAll(" ", "-");
383+
return propertiesService.getBaseUrl() + "/projects/" + pullRequest.getToRef().getRepository().getProject().getKey()
384+
+ "/repos/" + pullRequest.getToRef().getRepository().getSlug() + "/pull-requests/" + pullRequest.getId();
386385
}
387386

388387
PrnfsVariable(Resolver resolver) {

src/test/java/se/bjurr/prnfs/admin/PrnfsPullRequestEventListenerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ public void testThatAUrlWithVariablesExceptFromAndToCanBeInvoked() throws Except
414414
pullRequestRefBuilder() //
415415
.withProjectKey("theProject") //
416416
.withRepositoryName("the Repo Name") //
417+
.withRepositorySlug("the-repo-name") //
417418
) //
418419
.withPullRequestAction(OPENED) //
419420
.withAuthor( //
@@ -429,7 +430,7 @@ public void testThatAUrlWithVariablesExceptFromAndToCanBeInvoked() throws Except
429430
) //
430431
.invokedUrl(
431432
0,
432-
"http://bjurr.se/id=10&action=OPENED&displayName=authorDisplayName&authorEmail=authorEmail&authorId=100&authorName=authorName&authorSlug=authorSlug&pullRequestUrl=http%3A%2F%2Fstash.server%2Fprojects%2FtheProject%2Frepos%2Fthe-Repo-Name%2Fpull-requests%2F10" //
433+
"http://bjurr.se/id=10&action=OPENED&displayName=authorDisplayName&authorEmail=authorEmail&authorId=100&authorName=authorName&authorSlug=authorSlug&pullRequestUrl=http%3A%2F%2Fstash.server%2Fprojects%2FtheProject%2Frepos%2Fthe-repo-name%2Fpull-requests%2F10" //
433434
);
434435
}
435436

0 commit comments

Comments
 (0)