From bd081d780a328c7923725eae18ac7b17491c024f Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 10 Feb 2012 21:48:10 +0400 Subject: [PATCH] GitUIUtil.getShortRepositoryName: let it work for roots as VirtualFiles --- plugins/git4idea/src/git4idea/util/GitUIUtil.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/util/GitUIUtil.java b/plugins/git4idea/src/git4idea/util/GitUIUtil.java index 13233f15adcb..139614143641 100644 --- a/plugins/git4idea/src/git4idea/util/GitUIUtil.java +++ b/plugins/git4idea/src/git4idea/util/GitUIUtil.java @@ -500,12 +500,12 @@ public class GitUIUtil { } @NotNull - public static String getShortRepositoryName(@NotNull GitRepository repository) { - VirtualFile projectDir = repository.getProject().getBaseDir(); + public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) { + VirtualFile projectDir = project.getBaseDir(); - String repositoryPath = repository.getPresentableUrl(); + String repositoryPath = root.getPresentableUrl(); if (projectDir != null) { - String relativePath = VfsUtilCore.getRelativePath(repository.getRoot(), projectDir, File.separatorChar); + String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar); if (relativePath != null) { repositoryPath = relativePath; } @@ -513,4 +513,9 @@ public class GitUIUtil { return repositoryPath.isEmpty() ? "" : repositoryPath; } + + @NotNull + public static String getShortRepositoryName(@NotNull GitRepository repository) { + return getShortRepositoryName(repository.getProject(), repository.getRoot()); + } }