/// <inheritdoc/> public async Task CloneRepository( string cloneUrl, string repositoryName, string repositoryPath, object progress = null) { Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl)); Guard.ArgumentNotEmptyString(repositoryName, nameof(repositoryName)); Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath)); string path = Path.Combine(repositoryPath, repositoryName); // Switch to a thread pool thread for IO then back to the main thread to call // vsGitServices.Clone() as this must be called on the main thread. await ThreadingHelper.SwitchToPoolThreadAsync(); operatingSystem.Directory.CreateDirectory(path); await ThreadingHelper.SwitchToMainThreadAsync(); try { await vsGitServices.Clone(cloneUrl, path, true, progress); await usageTracker.IncrementCloneCount(); } catch (Exception ex) { log.Error(ex, "Could not clone {CloneUrl} to {Path}", cloneUrl, path); throw; } }
/// <inheritdoc/> public async Task CloneRepository( string cloneUrl, string repositoryPath, object progress = null) { Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl)); Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath)); // Switch to a thread pool thread for IO then back to the main thread to call // vsGitServices.Clone() as this must be called on the main thread. await ThreadingHelper.SwitchToPoolThreadAsync(); operatingSystem.Directory.CreateDirectory(repositoryPath); await ThreadingHelper.SwitchToMainThreadAsync(); try { await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress); await usageTracker.IncrementCounter(x => x.NumberOfClones); if (repositoryPath.StartsWith(DefaultClonePath, StringComparison.OrdinalIgnoreCase)) { // Count the number of times users clone into the Default Repository Location await usageTracker.IncrementCounter(x => x.NumberOfClonesToDefaultClonePath); } } catch (Exception ex) { log.Error(ex, "Could not clone {CloneUrl} to {Path}", cloneUrl, repositoryPath); throw; } }
/// <inheritdoc/> public async Task Refresh() { await ThreadingHelper.SwitchToPoolThreadAsync(); var list = vsGitServices.GetKnownRepositories(); await ThreadingHelper.SwitchToMainThreadAsync(); repositories.Except(list).ToList().ForEach(x => repositories.Remove(x)); list.Except(repositories).ToList().ForEach(x => repositories.Add(x)); }
/// <inheritdoc/> public async Task CloneRepository( string cloneUrl, string repositoryPath, object progress = null) { Guard.ArgumentNotEmptyString(cloneUrl, nameof(cloneUrl)); Guard.ArgumentNotEmptyString(repositoryPath, nameof(repositoryPath)); // Switch to a thread pool thread for IO then back to the main thread to call // vsGitServices.Clone() as this must be called on the main thread. await ThreadingHelper.SwitchToPoolThreadAsync(); operatingSystem.Directory.CreateDirectory(repositoryPath); await ThreadingHelper.SwitchToMainThreadAsync(); try { await vsGitServices.Clone(cloneUrl, repositoryPath, true, progress); await usageTracker.IncrementCounter(x => x.NumberOfClones); var repositoryUrl = new UriString(cloneUrl).ToRepositoryUrl(); var isDotCom = HostAddress.IsGitHubDotComUri(repositoryUrl); if (isDotCom) { await usageTracker.IncrementCounter(x => x.NumberOfGitHubClones); } else { // If it isn't a GitHub URL, assume it's an Enterprise URL await usageTracker.IncrementCounter(x => x.NumberOfEnterpriseClones); } } catch (Exception ex) { log.Error(ex, "Could not clone {CloneUrl} to {Path}", cloneUrl, repositoryPath); throw; } }