diff --git a/plugins/git4idea/resources/META-INF/plugin.xml b/plugins/git4idea/resources/META-INF/plugin.xml index 6e2f13fb0e1f..88e4e3f0c7e3 100644 --- a/plugins/git4idea/resources/META-INF/plugin.xml +++ b/plugins/git4idea/resources/META-INF/plugin.xml @@ -185,6 +185,11 @@ + + + + diff --git a/plugins/git4idea/src/git4idea/actions/CopyRepositoryRootPathProvider.kt b/plugins/git4idea/src/git4idea/actions/CopyRepositoryRootPathProvider.kt new file mode 100644 index 000000000000..6b1ddc8c0fc0 --- /dev/null +++ b/plugins/git4idea/src/git4idea/actions/CopyRepositoryRootPathProvider.kt @@ -0,0 +1,20 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package git4idea.actions + +import com.intellij.ide.actions.CopyPathProvider +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VfsUtilCore +import com.intellij.openapi.vfs.VirtualFile +import git4idea.repo.GitRepositoryManager + +class CopyPathFromRepositoryRootProvider : CopyPathProvider() { + override fun getPathToElement(project: Project, virtualFile: VirtualFile?, editor: Editor?): String? { + if (virtualFile == null) return null + + val repository = GitRepositoryManager.getInstance(project).getRepositoryForFile(virtualFile) + if (repository == null) return null + + return VfsUtilCore.getRelativePath(virtualFile, repository.root) + } +} \ No newline at end of file