private void Clone(IHostedRepository repo) { string targetDir = GetTargetDir(); if (targetDir == null) return; string repoSrc = repo.CloneReadWriteUrl; string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir, false, string.Empty, null); var formProcess = new FormProcess(Settings.GitCommand, cmd); formProcess.ShowDialog(); if (formProcess.ErrorOccurred()) return; Repositories.RepositoryHistory.AddMostRecentRepository(targetDir); Settings.WorkingDir = targetDir; if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl)) { var error = GitCommandHelpers.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl); if (!string.IsNullOrEmpty(error)) MessageBox.Show(this, error, _strCouldNotAddRemote.Text); } Close(); }
private void PopulateBranchesComboAndEnableCreateButton(IHostedRemote remote, ComboBox comboBox) { ThreadHelper.JoinableTaskFactory.RunAsync( async() => { await TaskScheduler.Default; IHostedRepository hostedRepository = remote.GetHostedRepository(); var branches = hostedRepository.GetBranches(); await this.SwitchToMainThreadAsync(); comboBox.Items.Clear(); var selectItem = 0; var defaultBranch = hostedRepository.GetDefaultBranch(); for (var i = 0; i < branches.Count; i++) { if (branches[i].Name == defaultBranch) { selectItem = i; } comboBox.Items.Add(branches[i].Name); } if (branches.Count > 0) { comboBox.SelectedIndex = selectItem; } _createBtn.Enabled = true; }) .FileAndForget(); }
private void Clone(IHostedRepository repo) { string targetDir = GetTargetDir(); if (targetDir == null) { return; } string repoSrc = repo.CloneReadWriteUrl; string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir, false, string.Empty, null); var formProcess = new FormProcess(Settings.GitCommand, cmd); formProcess.ShowDialog(this); if (formProcess.ErrorOccurred()) { return; } Repositories.RepositoryHistory.AddMostRecentRepository(targetDir); Settings.WorkingDir = targetDir; if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl)) { var error = Settings.Module.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(this, error, _strCouldNotAddRemote.Text); } } Close(); }
private void Clone(IHostedRepository repo) { string targetDir = GetTargetDir(); if (targetDir == null) return; string repoSrc = repo.CloneReadWriteUrl; string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir); FormRemoteProcess formRemoteProcess = new FormRemoteProcess(new GitModule(null), Settings.GitCommand, cmd); formRemoteProcess.Remote = repoSrc; formRemoteProcess.ShowDialog(); if (formRemoteProcess.ErrorOccurred()) return; GitModule module = new GitModule(targetDir); if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl)) { var error = module.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl); if (!string.IsNullOrEmpty(error)) MessageBox.Show(this, error, _strCouldNotAddRemote.Text); } if (GitModuleChanged != null) GitModuleChanged(module); Close(); }
public IHostedRepository GetHostedRepository() { if (_hostedRepository == null) { _hostedRepository = _plugin.GetRepository(Owner, NameAtRemote); } return(_hostedRepository); }
private void SetCloneInfoText(IHostedRepository repo) { var moreInfo = !string.IsNullOrEmpty(addUpstreamRemoteAsCB.Text) ? string.Format(_strWillBeAddedAsARemote.Text, addUpstreamRemoteAsCB.Text.Trim()) : ""; if (tabControl.SelectedTab == searchReposPage) { cloneInfoText.Text = string.Format(_strWillCloneInfo.Text, repo.CloneReadWriteUrl, GetTargetDir(), moreInfo); } else if (tabControl.SelectedTab == myReposPage) { cloneInfoText.Text = string.Format(_strWillCloneWithPushAccess.Text, repo.CloneReadWriteUrl, GetTargetDir(), moreInfo); } }
private void Clone(IHostedRepository repo) { string targetDir = GetTargetDir(); if (targetDir == null) { return; } string repoSrc = repo.CloneReadWriteUrl; string cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir); FormRemoteProcess formRemoteProcess = new FormRemoteProcess(new GitModule(null), AppSettings.GitCommand, cmd); formRemoteProcess.Remote = repoSrc; formRemoteProcess.ShowDialog(); if (formRemoteProcess.ErrorOccurred()) { return; } GitModule module = new GitModule(targetDir); if (_addRemoteAsTB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl)) { var error = module.AddRemote(_addRemoteAsTB.Text.Trim(), repo.ParentReadOnlyUrl); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(this, error, _strCouldNotAddRemote.Text); } } if (GitModuleChanged != null) { GitModuleChanged(this, new GitModuleEventArgs(module)); } Close(); }
private void Clone(IHostedRepository repo) { string targetDir = GetTargetDir(); if (targetDir == null) { return; } string repoSrc = repo.CloneReadWriteUrl; var cmd = GitCommandHelpers.CloneCmd(repoSrc, targetDir, depth: GetDepth()); var formRemoteProcess = new FormRemoteProcess(new GitModule(null), AppSettings.GitCommand, cmd) { Remote = repoSrc }; formRemoteProcess.ShowDialog(); if (formRemoteProcess.ErrorOccurred()) { return; } var module = new GitModule(targetDir); if (addUpstreamRemoteAsCB.Text.Trim().Length > 0 && !string.IsNullOrEmpty(repo.ParentReadOnlyUrl)) { var error = module.AddRemote(addUpstreamRemoteAsCB.Text.Trim(), repo.ParentReadOnlyUrl); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(this, error, _strCouldNotAddRemote.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } _gitModuleChanged?.Invoke(this, new GitModuleEventArgs(module)); Close(); }
private string GetTargetDir(IHostedRepository repo) { string targetDir = _destinationTB.Text.Trim(); if (targetDir.Length == 0) { MessageBox.Show(this, _strCloneFolderCanNotBeEmpty.Text, _strError.Text); return null; } targetDir = Path.Combine(targetDir, _createDirTB.Text); return targetDir; }