void UpdatePackage(String package) { try { String fullpath = Path.Combine(GlobalRegistry.Instance.Path, package); if (!Directory.Exists(fullpath)) { MessageBox.Show(String.Format("Unable to update package {0}, directory does not exist.", package), "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { m_ProgressForm = new ProgressDialog(); m_ProgressForm.WriteLine("Updating package {0}", package); String wd = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(fullpath); m_ProgressForm.QueueCommand("git reset --hard"); m_ProgressForm.QueueCommand("git pull"); m_ProgressForm.ShowDialog(); Directory.SetCurrentDirectory(wd); m_ProgressForm.WriteLine("Done updating package {0}.", package); } } catch (Exception exc) { MessageBox.Show("Error updating package:\n" + exc.Message, "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void ClonePackage(String source, String branch, String package) { try { String fullpath = Path.Combine(GlobalRegistry.Instance.Path, package); if (Directory.Exists(fullpath)) { MessageBox.Show(String.Format("Unable to install package {0}, directory already exists.", package), "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { m_ProgressForm = new ProgressDialog(); m_ProgressForm.WriteLine("Installing package {0}", package); String wd = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(GlobalRegistry.Instance.Path); m_ProgressForm.QueueCommand(String.Format("git clone \"{0}.git\" \"{1}\"", source, fullpath)); m_ProgressForm.QueueCommand ( delegate() { Directory.SetCurrentDirectory(fullpath); }, String.Format("git checkout \"{0}\"", branch), delegate() { Directory.SetCurrentDirectory(wd); } ); m_ProgressForm.ShowDialog(); } } catch (Exception exc) { MessageBox.Show("Error installing package:\n" + exc.Message, "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void StartupCheck() { if (!GitInPath()) { m_ProgressForm = new ProgressDialog(); m_ProgressForm.WriteLine("Unable to locate git for package management."); WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadFileAsync(new Uri("http://msysgit.googlecode.com/files/Git-1.7.8-preview20111206.exe"), "msysgit.exe"); m_ProgressForm.Show(this); m_ProgressForm.WriteLine("Downloading git installer..."); } }
void RemovePackage(String package) { try { String fullpath = Path.Combine(GlobalRegistry.Instance.Path, package); if (Directory.Exists(fullpath)) { Directory.Delete(fullpath, true); } m_ProgressForm.WriteLine("Done removing package {0}.", package); } catch (System.Exception exc) { MessageBox.Show("Error removing package:\n" + exc.Message, "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }