GitUIUtil.getShortRepositoryName: let it work for roots as VirtualFiles

This commit is contained in:
Kirill Likhodedov
2012-02-13 10:15:53 +04:00
parent 7831b6123f
commit bd081d780a
@@ -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() ? "<Project>" : repositoryPath;
}
@NotNull
public static String getShortRepositoryName(@NotNull GitRepository repository) {
return getShortRepositoryName(repository.getProject(), repository.getRoot());
}
}