Ejemplo n.º 1
0
        private void showGitHistoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var f = new GitLogForm();

            f.MdiParent = this;
            f.Show();
        }
Ejemplo n.º 2
0
        public void ShowGitDiff(string file, params int[] revs)
        {
            try
            {
                var fi = new FileInfo(file);

                var tempPath = Application.StartupPath + @"\temp";
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                var list = new List <string>();

                Common.Async.ExecAsync(this, (b) =>
                {
                    var ps = new Process();

                    ps.StartInfo = new ProcessStartInfo("git", @"-C """ + fi.DirectoryName + @""" log --pretty=format:""%H"" """ + fi.Name + @"""");

                    ps.StartInfo.CreateNoWindow         = true;
                    ps.StartInfo.RedirectStandardOutput = true;
                    ps.StartInfo.RedirectStandardError  = true;
                    ps.StartInfo.UseShellExecute        = false;

                    ps.Start();
                    ps.WaitForExit();


                    while (!ps.StandardOutput.EndOfStream)
                    {
                        string line = ps.StandardOutput.ReadLine();
                        list.Add(line);
                    }

                    if (list.Count == 0)
                    {
                        Syncronized(() => MessageBox.Show("No Git repo found", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1));
                        return;
                    }
                    var file1 = GitLogForm.GetGitFile(list[0], file);
                    var file2 = file;

                    var ps2       = new Process();
                    ps2.StartInfo = new ProcessStartInfo("TortoiseMerge", " /base:\"" + file1 + "\" /mine:\"" + file2 + "\"");
                    ps2.Start();
                }, (tm) => toolStripStatusLabel.Text = tm.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void gitLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabForms.TabCount > 0 && tabForms.SelectedTab != null)
            {
                var form = (tabForms.SelectedTab.Tag as Form);
                var file = (form as IChildForm).FileName;

                var list = new List <string>();

                var tempPath = Application.StartupPath + @"\temp";
                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                Common.Async.ExecAsync(form, (b) => {
                    var ps = new Process();

                    var fi = new FileInfo(file);

                    var tempFile = tempPath + @"\" + Guid.NewGuid().ToString("N");
                    var str      = @"git -C """ + fi.DirectoryName + @""" log --pretty=format:""%H♦%cn♦%s♦%aI"" """ + fi.Name + @""" > """ + tempFile + @"""";
                    ps.StartInfo = new ProcessStartInfo("cmd", "/c " + str);
                    ps.StartInfo.UseShellExecute = true;
                    ps.Start();
                    ps.WaitForExit();

                    list.AddRange(File.ReadAllLines(tempFile));
                }, (elapsed) => {
                    toolStripStatusLabel.Text = elapsed.ToString();
                    var f = new GitLogForm(file);
                    f.SetLog(list);
                    f.ShowDialog();
                });
            }
        }