зеркало из https://github.com/github/VisualStudio.git
Handle when just owner has been deleted
Don't include old the repository name when next repository is selected.
This commit is contained in:
Родитель
fca3a96eee
Коммит
785c5f6659
|
@ -25,7 +25,7 @@ namespace GitHub.ViewModels.Dialog.Clone
|
|||
readonly IRepositoryCloneService service;
|
||||
readonly IReadOnlyList<IRepositoryCloneTabViewModel> tabs;
|
||||
string path;
|
||||
string previousOwner;
|
||||
IRepositoryModel previousRepository;
|
||||
ObservableAsPropertyHelper<string> pathError;
|
||||
int selectedTabIndex;
|
||||
|
||||
|
@ -143,25 +143,38 @@ namespace GitHub.ViewModels.Dialog.Clone
|
|||
{
|
||||
if (repository != null)
|
||||
{
|
||||
var basePath = GetBasePath(Path, previousOwner);
|
||||
previousOwner = repository.Owner;
|
||||
var basePath = GetUpdatedBasePath(Path);
|
||||
previousRepository = repository;
|
||||
Path = System.IO.Path.Combine(basePath, repository.Owner, repository.Name);
|
||||
}
|
||||
}
|
||||
|
||||
string GetBasePath(string path, string owner)
|
||||
string GetUpdatedBasePath(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return service.DefaultClonePath;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(owner))
|
||||
if (previousRepository == null)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
var dir = path;
|
||||
if (FindDirWithout(path, previousRepository?.Owner, 2) is string dirWithoutOwner)
|
||||
{
|
||||
return dirWithoutOwner;
|
||||
}
|
||||
|
||||
if (FindDirWithout(path, previousRepository?.Name, 1) is string dirWithoutRepo)
|
||||
{
|
||||
return dirWithoutRepo;
|
||||
}
|
||||
|
||||
return path;
|
||||
|
||||
string FindDirWithout(string dir, string match, int levels)
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dir))
|
||||
|
@ -171,13 +184,14 @@ namespace GitHub.ViewModels.Dialog.Clone
|
|||
|
||||
var name = System.IO.Path.GetFileName(dir);
|
||||
dir = System.IO.Path.GetDirectoryName(dir);
|
||||
if (name == owner)
|
||||
if (name == match)
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string ValidatePath(IRepositoryModel repository, string path)
|
||||
|
|
Загрузка…
Ссылка в новой задаче