Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use modern clone/open dialog when re-cloning
Use the same open/clone dialog when cloning or re-cloning a respository
repository that has been cloned before.
  • Loading branch information
jcansdale committed Jan 28, 2019
commit 1da1d9f007fbf1cce7068511784bde6bc4717b56
24 changes: 4 additions & 20 deletions src/GitHub.StartPage/StartPagePackage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -90,39 +89,24 @@ async Task<CloneDialogResult> ShowCloneDialog(
var dialogService = gitHubServiceProvider.GetService<IDialogService>();
var cloneService = gitHubServiceProvider.GetService<IRepositoryCloneService>();
var usageTracker = gitHubServiceProvider.GetService<IUsageTracker>();
CloneDialogResult result = null;

if (repository == null)
{
result = await dialogService.ShowCloneDialog(null);
}
else
{
var basePath = await dialogService.ShowReCloneDialog(repository);

if (basePath != null)
{
var path = Path.Combine(basePath, repository.Name);
result = new CloneDialogResult(path, repository.CloneUrl);
}
}

if (result != null)
var cloneUrl = repository?.CloneUrl;
if (await dialogService.ShowCloneDialog(null, cloneUrl) is CloneDialogResult result)
{
try
{
await cloneService.CloneOrOpenRepository(result, progress, cancellationToken);
usageTracker.IncrementCounter(x => x.NumberOfStartPageClones).Forget();
return result;
}
catch
{
var teServices = gitHubServiceProvider.TryGetService<ITeamExplorerServices>();
teServices.ShowError($"Failed to clone the repository '{result.Url.RepositoryName}'");
result = null;
}
}

return result;
return null;
}
}
}