private GitClientFactory getGitClientFactory(string localFolder) { if (_gitClientFactory == null || _gitClientFactory.ParentFolder != localFolder) { _gitClientFactory?.Dispose(); try { _gitClientFactory = new GitClientFactory(localFolder, _updateManager.GetProjectWatcher()); } catch (ArgumentException ex) { ExceptionHandlers.Handle(ex, String.Format("Cannot create GitClientFactory")); try { Directory.CreateDirectory(localFolder); } catch (Exception ex2) { string message = String.Format("Cannot create folder \"{0}\"", localFolder); ExceptionHandlers.Handle(ex2, message); MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } } } return(_gitClientFactory); }
/// <summary> /// Make some checks and create a Client /// </summary> /// <returns>null if could not create a GitClient</returns> private GitClient getGitClient(string hostname, string projectname) { GitClientFactory factory = getGitClientFactory(_settings.LocalGitFolder); if (factory == null) { return(null); } GitClient client; try { client = factory.GetClient(hostname, projectname); } catch (ArgumentException ex) { ExceptionHandlers.Handle(ex, String.Format("Cannot create GitClient")); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } Debug.Assert(client != null); return(client); }
public void Handle(Snapshot snapshot) { using (GitClientFactory factory = new GitClientFactory(snapshot.TempFolder, null)) { IGitRepository gitRepository = factory.GetClient(snapshot.Host, snapshot.Project); DiffToolInfoProcessor processor = new DiffToolInfoProcessor(gitRepository); DiffToolInfo diffToolInfo; if (!processor.Process(_originalDiffToolInfo, snapshot.Refs, out diffToolInfo)) { return; } RefToLineMatcher matcher = new RefToLineMatcher(gitRepository); DiffPosition position = matcher.Match(snapshot.Refs, diffToolInfo); NewDiscussionForm form = new NewDiscussionForm(snapshot, diffToolInfo, position, gitRepository); if (form.ShowDialog() == DialogResult.OK) { submitDiscussion(snapshot, diffToolInfo, position, form.Body, form.IncludeContext); } } }