Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
25 changes: 0 additions & 25 deletions src/GitHub.App/SampleData/RepositoryRecloneViewModelDesigner.cs

This file was deleted.

9 changes: 0 additions & 9 deletions src/GitHub.App/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ public async Task<CloneDialogResult> ShowCloneDialog(IConnection connection, str
}
}

public async Task<string> ShowReCloneDialog(RepositoryModel repository)
{
Guard.ArgumentNotNull(repository, nameof(repository));

var viewModel = factory.CreateViewModel<IRepositoryRecloneViewModel>();
viewModel.SelectedRepository = repository;
return (string)await showDialog.ShowWithFirstConnection(viewModel);
}

public async Task ShowCreateGist(IConnection connection)
{
var viewModel = factory.CreateViewModel<IGistCreationViewModel>();
Expand Down
10 changes: 6 additions & 4 deletions src/GitHub.App/Services/RepositoryCloneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
/// <inheritdoc/>
public async Task CloneOrOpenRepository(
CloneDialogResult cloneDialogResult,
object progress = null)
object progress = null,
CancellationToken? cancellationToken = null)
{
Guard.ArgumentNotNull(cloneDialogResult, nameof(cloneDialogResult));

Expand Down Expand Up @@ -147,7 +148,7 @@ public async Task CloneOrOpenRepository(
else
{
var cloneUrl = repositoryUrl.ToString();
await CloneRepository(cloneUrl, repositoryPath, progress).ConfigureAwait(true);
await CloneRepository(cloneUrl, repositoryPath, progress, cancellationToken).ConfigureAwait(true);

if (isDotCom)
{
Expand Down Expand Up @@ -197,7 +198,8 @@ bool IsSolutionInRepository(string repositoryPath)
public async Task CloneRepository(
string cloneUrl,
string repositoryPath,
object progress = null)
object progress = null,
CancellationToken? cancellationToken = null)
{
Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl));
Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath));
Expand All @@ -210,7 +212,7 @@ public async Task CloneRepository(

try
{
await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress);
await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress, cancellationToken);
await usageTracker.IncrementCounter(x => x.NumberOfClones);

if (repositoryPath.StartsWith(DefaultClonePath, StringComparison.OrdinalIgnoreCase))
Expand Down
162 changes: 0 additions & 162 deletions src/GitHub.App/ViewModels/Dialog/RepositoryRecloneViewModel.cs

This file was deleted.

10 changes: 6 additions & 4 deletions src/GitHub.Exports.Reactive/Services/IRepositoryCloneService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Models;
using GitHub.Primitives;
Expand Down Expand Up @@ -27,11 +26,13 @@ public interface IRepositoryCloneService
/// System.IProgress&lt;Microsoft.VisualStudio.Shell.ServiceProgressData&gt;, but
/// as that type is only available in VS2017+ it is typed as <see cref="object"/> here.
/// </param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <returns></returns>
Task CloneRepository(
string cloneUrl,
string repositoryPath,
object progress = null);
object progress = null,
CancellationToken? cancellationToken = null);

/// <summary>
/// Clones the specified repository into the specified directory or opens it if the directory already exists.
Expand All @@ -45,7 +46,8 @@ Task CloneRepository(
/// <returns></returns>
Task CloneOrOpenRepository(
CloneDialogResult cloneDialogResult,
object progress = null);
object progress = null,
CancellationToken? cancellationToken = null);

/// <summary>
/// Checks whether the specified destination directory already exists.
Expand Down

This file was deleted.

14 changes: 0 additions & 14 deletions src/GitHub.Exports/Services/IDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ public interface IDialogService
/// </returns>
Task<CloneDialogResult> ShowCloneDialog(IConnection connection, string url = null);

/// <summary>
/// Shows the re-clone dialog.
/// </summary>
/// <param name="repository">The repository to clone.</param>
/// <returns>
/// A task that returns the base path for the clone on success, or null if the dialog was
/// cancelled.
/// </returns>
/// <remarks>
/// The re-clone dialog is shown from the VS2017+ start page when the user wants to check
/// out a repository that was previously checked out on another machine.
/// </remarks>
Task<string> ShowReCloneDialog(RepositoryModel repository);

/// <summary>
/// Shows the Create Gist dialog.
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/GitHub.Exports/Services/IVSGitServices.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Models;

Expand All @@ -20,13 +21,15 @@ public interface IVSGitServices
/// System.IProgress&lt;Microsoft.VisualStudio.Shell.ServiceProgressData&gt;, but
/// as that type is only available in VS2017+ it is typed as <see cref="object"/> here.
/// </param>
/// <param name="cancellationToken">A cancellation token.</param>
/// <seealso cref="System.IProgress{T}"/>
/// <seealso cref="Microsoft.VisualStudio.Shell.ServiceProgressData"/>
Task Clone(
string cloneUrl,
string clonePath,
bool recurseSubmodules,
object progress = null);
object progress = null,
CancellationToken? cancellationToken = null);

string GetActiveRepoPath();
LibGit2Sharp.IRepository GetActiveRepo();
Expand Down
29 changes: 7 additions & 22 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 @@ -57,7 +56,7 @@ async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> download
try
{
var uiProvider = await Task.Run(() => Package.GetGlobalService(typeof(IGitHubServiceProvider)) as IGitHubServiceProvider);
request = await ShowCloneDialog(uiProvider, downloadProgress, repository);
request = await ShowCloneDialog(uiProvider, downloadProgress, cancellationToken, repository);
}
catch (Exception e)
{
Expand All @@ -84,44 +83,30 @@ async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> download
async Task<CloneDialogResult> ShowCloneDialog(
IGitHubServiceProvider gitHubServiceProvider,
IProgress<ServiceProgressData> progress,
CancellationToken cancellationToken,
RepositoryModel repository = null)
{
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);
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;
}
}
}
Loading