mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
GitUIUtil.getShortRepositoryName: let it work for roots as VirtualFiles
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user