Skip to content

Commit

Permalink
Update GitLab URL template
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-gibson committed Aug 29, 2024
1 parent 13296a0 commit 525b5cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class PlatformDetector(val project: Project) {
getRepositoryForFile(projectDirectory) { repository -> getPlatformForRepository(repository).let(consumer) }
}

private fun getPlatformForRepository(repository: GitRepository?): Platform? {
repository ?: return null

private fun getPlatformForRepository(repository: GitRepository): Platform? {
val settings = project.service<ProjectSettings>()

val remote = repository.locateRemote(settings.remote) ?: return null
Expand All @@ -41,7 +39,7 @@ class PlatformDetector(val project: Project) {
}
}

private fun getRepositoryForFile(projectDirectory: VirtualFile, consumer: (GitRepository?) -> Unit) {
private fun getRepositoryForFile(projectDirectory: VirtualFile, consumer: (GitRepository) -> Unit) {
val gitRepositoryManager = GitRepositoryManager.getInstance(project)
val repository = gitRepositoryManager.getRepositoryForFile(projectDirectory)
if (repository != null) {
Expand All @@ -55,7 +53,7 @@ class PlatformDetector(val project: Project) {
VcsRepositoryManager.VCS_REPOSITORY_MAPPING_UPDATED,
VcsRepositoryMappingListener {
busConnection.disconnect()
gitRepositoryManager.getRepositoryForFile(projectDirectory).let(consumer)
gitRepositoryManager.getRepositoryForFile(projectDirectory)?.let(consumer)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ data class UrlTemplates(val fileAtBranch: String, val fileAtCommit : String, val

fun gitLab(): UrlTemplates {
return UrlTemplates(
"{remote:url}/-/{object}/{branch}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end}",
"{remote:url}/-/{object}/{commit}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end}",
"{remote:url}/-/commit/{commit}"
"{remote:url}/{object}/{branch}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end}",
"{remote:url}/{object}/{commit}/{file:path}/{file:name}{line-block:start}#L{line:start}-{line:end}{line-block:end}",
"{remote:url}/commit/{commit}"
)
}

Expand Down

0 comments on commit 525b5cf

Please sign in to comment.