diff --git a/src/main/kotlin/com/github/shiraji/findpullrequest/annotation/ListPullRequestTextAnnotationGutterProvider.kt b/src/main/kotlin/com/github/shiraji/findpullrequest/annotation/ListPullRequestTextAnnotationGutterProvider.kt index da5f1d8..d3b63fe 100644 --- a/src/main/kotlin/com/github/shiraji/findpullrequest/annotation/ListPullRequestTextAnnotationGutterProvider.kt +++ b/src/main/kotlin/com/github/shiraji/findpullrequest/annotation/ListPullRequestTextAnnotationGutterProvider.kt @@ -75,7 +75,7 @@ class ListPullRequestTextAnnotationGutterProvider( BrowserUtil.open(url) } else { val path = hostingService.urlPathFormat.format(gitPullRequestInfo.prNumber) - val url = model.createUrl(repository, hostingService, path) + val url = model.createPRUrl(repository, hostingService, path) BrowserUtil.open("$webRepoUrl/$url") } diff --git a/src/main/kotlin/com/github/shiraji/findpullrequest/model/FindPullRequestModel.kt b/src/main/kotlin/com/github/shiraji/findpullrequest/model/FindPullRequestModel.kt index 85bbf6c..614910f 100644 --- a/src/main/kotlin/com/github/shiraji/findpullrequest/model/FindPullRequestModel.kt +++ b/src/main/kotlin/com/github/shiraji/findpullrequest/model/FindPullRequestModel.kt @@ -39,7 +39,12 @@ class FindPullRequestModel( fun createCommitUrl(repository: GitRepository, hostingServices: FindPullRequestHostingServices, webRepoUrl: String, revisionHash: VcsRevisionNumber): String { val path = hostingServices.commitPathFormat.format(webRepoUrl, revisionHash) - return createUrl(repository, hostingServices, path) + return if (config.isJumpToFile()) { + val fileAnnotation = gitConfService.getFileAnnotation(repository, virtualFile) ?: return path + path + hostingServices.createFileAnchorValue(repository, fileAnnotation) + } else { + path + } } fun createPullRequestPath(repository: GitRepository, revisionHash: VcsRevisionNumber): String { @@ -68,7 +73,7 @@ class FindPullRequestModel( } val path = targetHostingService.urlPathFormat.format(prNumber) - createUrl(repository, targetHostingService, path) + createPRUrl(repository, targetHostingService, path) } else { val commit = gitHistoryService.findCommitLog(project, repository, revisionHash) val hostingServices = FindPullRequestHostingServices.values().firstOrNull { @@ -77,14 +82,14 @@ class FindPullRequestModel( if (hostingServices != null) { val path = hostingServices.urlPathFormat.format(commit.getNumberFromCommitMessage(hostingServices.squashCommitMessage)) - createUrl(repository, hostingServices, path) + createPRUrl(repository, hostingServices, path) } else { throw NoPullRequestFoundException(debugMessage.toString()) } } } - fun createUrl(repository: GitRepository, hostingServices: FindPullRequestHostingServices, path: String): String { + fun createPRUrl(repository: GitRepository, hostingServices: FindPullRequestHostingServices, path: String): String { return if (config.isJumpToFile()) { val fileAnnotation = gitConfService.getFileAnnotation(repository, virtualFile) ?: return path path + hostingServices.urlPathForDiff + hostingServices.createFileAnchorValue(repository, fileAnnotation)