public GitFilePersister(string path, RepositoryCloneType cloneType, string userName, string passwd, string clonePath = "", bool cloneAllBranches = true) { ClonePath = clonePath; UrlPath = path; IsCloned = false; CloneRepository(cloneType, userName, passwd, cloneAllBranches); }
private void CloneRepository(RepositoryCloneType cloneType = RepositoryCloneType.Public, string userName = "", string passwd = "", bool cloneAllBranches = true) { GitCloneService cloneService = new GitCloneService(UrlPath, ClonePath); if (cloneType == RepositoryCloneType.Public) { cloneService.CloneRepository(cloneAllBranches); } else { cloneService.CloneRepository(cloneAllBranches, cloneType, userName, passwd); } IsCloned = true; DirectoryPath = cloneService.DirectoryPath; }
public void CloneRepository(bool cloneWithAllBranches = false, RepositoryCloneType repositoryCloneType = RepositoryCloneType.Public, string userName = "", string passwd = "") { if (!UrlAdress.EndsWith(".git")) { UrlAdress += ".git"; } string repositoryPath = string.IsNullOrEmpty(this.ClonePath) ? "./" + GetRepositoryNameFromUrl(UrlAdress) : ZetaLongPaths.ZlpPathHelper.Combine(this.ClonePath, GetRepositoryNameFromUrl(UrlAdress)); if (!Directory.Exists(repositoryPath)) { Directory.CreateDirectory(repositoryPath); } else { DeleteDirectory(repositoryPath, true); } if (repositoryCloneType == RepositoryCloneType.Public) { Repository.Clone(UrlAdress, repositoryPath); } else { Repository.Clone(UrlAdress, repositoryPath, new CloneOptions() { CredentialsProvider = (url, dd, a) => new UsernamePasswordCredentials() { Username = userName, Password = passwd } }); } DirectoryPath = repositoryPath; if (cloneWithAllBranches) { FillBranches(); CloneAllBranches(); } }
public async void OpenRepository() { if (!string.IsNullOrEmpty(UrlTextBox)) { _isLocal = SetIsLocal(); try { IsLoading = true; if (IsGitRepositoryPicked) { RepositoryCloneType currentRepositoryType = RepositoryCloneType.Public; string username = string.Empty, password = string.Empty; if (!_isLocal && GitCloneService.CheckRepositoryCloneType(UrlTextBox) == RepositoryCloneType.Private) { currentRepositoryType = RepositoryCloneType.Private; var loginResult = await _dialogCoordinator.ShowLoginAsync(ViewModelLocator.Instance.Main, this.GetLocalizedString("LoginInformation"), this.GetLocalizedString("EnterCredentials")); if (loginResult != null) { username = loginResult.Username; password = loginResult.Password; } } await Task.Run(() => { this.IsOpening = true; switch (currentRepositoryType) { case RepositoryCloneType.Private: _repositoryFilePersister = new GitFilePersister(UrlTextBox, RepositoryCloneType.Private, username, password, ConfigurationService.Instance.Configuration.SavingRepositoryPath, ConfigurationService.Instance.Configuration.CloneAllBranches); break; case RepositoryCloneType.Public: _repositoryFilePersister = new GitFilePersister(this.UrlTextBox, !_isLocal, ConfigurationService.Instance.Configuration.SavingRepositoryPath, ConfigurationService.Instance.Configuration.CloneAllBranches); break; } _repositoryFilePersister.AddRepositoryToDataBase(DbService.Instance.SessionFactory); }); } else { await Task.Run(() => { _repositoryFilePersister = new SvnFilePersister(UrlTextBox); _repositoryFilePersister.AddRepositoryToDataBase(DbService.Instance.SessionFactory); }); } this.UrlTextBox = string.Empty; Messenger.Default.Send <RefreshMessageToPresentation>(new RefreshMessageToPresentation(true)); ViewModelLocator.Instance.Filtering.ResetInitialization(); Messenger.Default.Send <RefreshMessageToFiltering>(new RefreshMessageToFiltering(true)); ViewModelLocator.Instance.Main.OnLoad(); } catch (Exception ex) { await DialogHelper.Instance.ShowDialog(new CustomDialogEntryData() { MetroWindow = StaticServiceProvider.MetroWindowInstance, DialogTitle = this.GetLocalizedString("Error"), DialogMessage = ex.Message, OkButtonMessage = "Ok", InformationType = InformationType.Error }); } finally { this.IsLoading = false; } } }