Пример #1
0
        private static void RunCommand(string[] args)
        {
            if (args.Length > 1)
            {
                switch (args[1])
                {
                    case "mergeconflicts":
                        GitUICommands.Instance.StartResolveConflictsDialog();
                        return;
                    case "gitbash":
                        GitCommandHelpers.RunBash();
                        return;
                    case "gitignore":
                        GitUICommands.Instance.StartEditGitIgnoreDialog();
                        return;
                    case "remotes":
                        GitUICommands.Instance.StartRemotesDialog();
                        return;
                    case "blame":
                        if (args.Length > 2)
                        {
                            // Remove working dir from filename. This is to prevent filenames that are too
                            // long while there is room left when the workingdir was not in the path.
                            string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                            GitUICommands.Instance.StartBlameDialog(fileName);
                        }
                        else
                            MessageBox.Show("Cannot open blame, there is no file selected.", "Blame");
                        return;
                    case "browse":
                        GitUICommands.Instance.StartBrowseDialog(GetParameterOrEmptyStringAsDefault(args, "-filter"));
                        return;
                    case "add":
                    case "addfiles":
                        GitUICommands.Instance.StartAddFilesDialog();
                        return;
                    case "apply":
                    case "applypatch":
                        GitUICommands.Instance.StartApplyPatchDialog();
                        return;
                    case "branch":
                        GitUICommands.Instance.StartCreateBranchDialog();
                        return;
                    case "checkout":
                    case "checkoutbranch":
                        GitUICommands.Instance.StartCheckoutBranchDialog();
                        return;
                    case "checkoutrevision":
                        GitUICommands.Instance.StartCheckoutRevisionDialog();
                        return;
                    case "init":
                        if (args.Length > 2)
                            GitUICommands.Instance.StartInitializeDialog(args[2]);
                        else
                            GitUICommands.Instance.StartInitializeDialog();
                        return;
                    case "clone":
                        GitUICommands.Instance.StartCloneDialog();
                        return;
                    case "commit":
                        GitUICommands.Instance.StartCommitDialog();
                        return;
                    case "filehistory":
                        if (args.Length > 2)
                        {
                            //Remove working dir from filename. This is to prevent filenames that are too
                            //long while there is room left when the workingdir was not in the path.
                            string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                            GitUICommands.Instance.StartFileHistoryDialog(fileName);
                        }
                        else
                            MessageBox.Show("Cannot open file history, there is no file selected.", "File history");
                        return;
                    case "fileeditor":
                        if (args.Length > 2)
                        {
                            using (var formEditor = new FormEditor(args[2]))
                            {
                                formEditor.ShowDialog();
                            }
                        }
                        else
                            MessageBox.Show("Cannot open file editor, there is no file selected.", "File editor");
                        return;
                    case "formatpatch":
                        GitUICommands.Instance.StartFormatPatchDialog();
                        return;
                    case "pull":
                        GitUICommands.Instance.StartPullDialog();
                        return;
                    case "push":
                        GitUICommands.Instance.StartPushDialog();
                        return;
                    case "settings":
                        GitUICommands.Instance.StartSettingsDialog();
                        return;
                    case "viewdiff":
                        GitUICommands.Instance.StartCompareRevisionsDialog();
                        return;
                    case "rebase":
                        GitUICommands.Instance.StartRebaseDialog(null);
                        return;
                    case "merge":
                        GitUICommands.Instance.StartMergeBranchDialog(null);
                        return;
                    case "cherry":
                        GitUICommands.Instance.StartCherryPickDialog();
                        return;
                    case "revert":
                        Application.Run(new FormRevert(args[2]));
                        return;
                    case "tag":
                        GitUICommands.Instance.StartCreateTagDialog();
                        return;
                    case "about":
                        Application.Run(new AboutBox());
                        return;
                    case "stash":
                        GitUICommands.Instance.StartStashDialog();
                        return;
                    default:
                        Application.Run(new FormCommandlineHelp());
                        return;
                }
            }
        }
Пример #2
0
 private void RunFileEditorCommand(string[] args)
 {
     using (var formEditor = new FormEditor(this, args[2]))
     {
         if (formEditor.ShowDialog() == DialogResult.Cancel)
             System.Environment.ExitCode = -1;
     }
 }
Пример #3
0
        private void editFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileStatusList list;
            if (!SenderToFileStatusList(sender, out list))
                return;

            var item = list.SelectedItem;
            var fileName = Module.WorkingDir + item.Name;

            using (var frm = new FormEditor(UICommands, fileName)) frm.ShowDialog(this);

            UntrackedSelectionChanged(null, null);
        }
Пример #4
0
        private void editCheckedOutFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var item = GitTree.SelectedNode.Tag;

            var gitItem = item as GitItem;
            if (gitItem == null || !gitItem.IsBlob)
                return;

            var fileName = Module.WorkingDir + (gitItem).FileName;
            using (var frm = new FormEditor(UICommands, fileName)) frm.ShowDialog(this);
        }
Пример #5
0
        private static void RunCommand(string[] args)
        {
            Dictionary<string, string> arguments = new Dictionary<string, string>();

            for (int i = 2; i < args.Length; i++)
            {
                if (args[i].StartsWith("--") && i + 1 < args.Length && !args[i + 1].StartsWith("--"))
                    arguments.Add(args[i].TrimStart('-'), args[++i]);
                else
                    if (args[i].StartsWith("--"))
                        arguments.Add(args[i].TrimStart('-'), null);
            }

            if (args.Length > 1)
            {
                switch (args[1])
                {
                    case "mergetool":
                    case "mergeconflicts":
                        if (!arguments.ContainsKey("quiet") || GitCommandHelpers.InTheMiddleOfConflictedMerge())
                            GitUICommands.Instance.StartResolveConflictsDialog();

                        return;
                    case "gitbash":
                        GitCommandHelpers.RunBash();
                        return;
                    case "gitignore":
                        GitUICommands.Instance.StartEditGitIgnoreDialog();
                        return;
                    case "remotes":
                        GitUICommands.Instance.StartRemotesDialog();
                        return;
                    case "blame":
                        if (args.Length > 2)
                        {
                            // Remove working dir from filename. This is to prevent filenames that are too
                            // long while there is room left when the workingdir was not in the path.
                            string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                            GitUICommands.Instance.StartBlameDialog(fileName);
                        }
                        else
                            MessageBox.Show("Cannot open blame, there is no file selected.", "Blame");
                        return;
                    case "browse":
                        GitUICommands.Instance.StartBrowseDialog(GetParameterOrEmptyStringAsDefault(args, "-filter"));
                        return;
                    case "cleanup":
                        new FormCleanupRepository().ShowDialog();
                        return;
                    case "add":
                    case "addfiles":
                        GitUICommands.Instance.StartAddFilesDialog();
                        return;
                    case "apply":
                    case "applypatch":
                        GitUICommands.Instance.StartApplyPatchDialog();
                        return;
                    case "branch":
                        GitUICommands.Instance.StartCreateBranchDialog();
                        return;
                    case "checkout":
                    case "checkoutbranch":
                        GitUICommands.Instance.StartCheckoutBranchDialog();
                        return;
                    case "checkoutrevision":
                        GitUICommands.Instance.StartCheckoutRevisionDialog();
                        return;
                    case "init":
                        if (args.Length > 2)
                            GitUICommands.Instance.StartInitializeDialog(args[2]);
                        else
                            GitUICommands.Instance.StartInitializeDialog();
                        return;
                    case "clone":
                        GitUICommands.Instance.StartCloneDialog();
                        return;
                    case "commit":
                        Commit(arguments);
                        return;
                    case "filehistory":
                        if (args.Length > 2)
                        {
                            //Remove working dir from filename. This is to prevent filenames that are too
                            //long while there is room left when the workingdir was not in the path.
                            string fileName = args[2].Replace(Settings.WorkingDir, "").Replace('\\', '/');

                            GitUICommands.Instance.StartFileHistoryDialog(fileName);
                        }
                        else
                            MessageBox.Show("Cannot open file history, there is no file selected.", "File history");
                        return;
                    case "fileeditor":
                        if (args.Length > 2)
                        {
                            using (var formEditor = new FormEditor(args[2]))
                            {
                                if (formEditor.ShowDialog() == DialogResult.Cancel)
                                    System.Environment.ExitCode = -1;
                            }
                        }
                        else
                            MessageBox.Show("Cannot open file editor, there is no file selected.", "File editor");
                        return;
                    case "formatpatch":
                        GitUICommands.Instance.StartFormatPatchDialog();
                        return;
                    case "pull":
                        Pull(arguments);
                        return;
                    case "push":
                        Push(arguments);
                        return;
                    case "settings":
                        GitUICommands.Instance.StartSettingsDialog();
                        return;
                    case "viewdiff":
                        GitUICommands.Instance.StartCompareRevisionsDialog();
                        return;
                    case "rebase":
                        {
                            string branch = null;
                            if (arguments.ContainsKey("branch"))
                                branch = arguments["branch"];
                            GitUICommands.Instance.StartRebaseDialog(branch);
                            return;
                        }
                    case "merge":
                        {
                            string branch = null;
                            if (arguments.ContainsKey("branch"))
                                branch = arguments["branch"];
                            GitUICommands.Instance.StartMergeBranchDialog(branch);
                            return;
                        }
                    case "cherry":
                        GitUICommands.Instance.StartCherryPickDialog();
                        return;
                    case "revert":
                        Application.Run(new FormRevert(args[2]));
                        return;
                    case "tag":
                        GitUICommands.Instance.StartCreateTagDialog();
                        return;
                    case "about":
                        Application.Run(new AboutBox());
                        return;
                    case "stash":
                        GitUICommands.Instance.StartStashDialog();
                        return;
                    case "synchronize":
                        Commit(arguments);
                        Pull(arguments);
                        Push(arguments);
                        return;
                    case "openrepo":
                        if (args.Length > 2)
                        {
                            if (File.Exists(args[2]))
                            {
                                string path = File.ReadAllText(args[2]);
                                if (Directory.Exists(path))
                                {
                                    Settings.WorkingDir = path;
                                }
                            }
                        }

                        GitUICommands.Instance.StartBrowseDialog();
                        return;
                    default:
                        Application.Run(new FormCommandlineHelp());
                        return;
                }
            }
        }
 internal static void RunFileEditorCommand(string[] args)
 {
     using (var formEditor = new FormEditor(args[2]))
     {
         if (formEditor.ShowDialog() == DialogResult.Cancel)
             Environment.ExitCode = -1;
     }
 }