コード例 #1
0
        private static void AddDefaultScripts()
        {
            ScriptInfo fetchAfterCommitScript = new ScriptInfo();

            fetchAfterCommitScript.HotkeyCommandIdentifier = 9000;
            fetchAfterCommitScript.Name            = "Fetch changes after commit";
            fetchAfterCommitScript.Command         = "git";
            fetchAfterCommitScript.Arguments       = "fetch";
            fetchAfterCommitScript.AskConfirmation = true;
            fetchAfterCommitScript.OnEvent         = ScriptEvent.AfterCommit;
            fetchAfterCommitScript.AddToRevisionGridContextMenu = false;
            fetchAfterCommitScript.Enabled = false;
            Scripts.Add(fetchAfterCommitScript);

            ScriptInfo updateSubmodulesAfterPullScript = new ScriptInfo();

            updateSubmodulesAfterPullScript.HotkeyCommandIdentifier = 9001;
            updateSubmodulesAfterPullScript.Name            = "Update submodules after pull";
            updateSubmodulesAfterPullScript.Command         = "git";
            updateSubmodulesAfterPullScript.Arguments       = "submodule update";
            updateSubmodulesAfterPullScript.AskConfirmation = true;
            updateSubmodulesAfterPullScript.OnEvent         = ScriptEvent.AfterPull;
            updateSubmodulesAfterPullScript.AddToRevisionGridContextMenu = false;
            updateSubmodulesAfterPullScript.Enabled = false;
            Scripts.Add(updateSubmodulesAfterPullScript);

            ScriptInfo userMenuScript = new ScriptInfo();

            userMenuScript.HotkeyCommandIdentifier = 9002;
            userMenuScript.Name            = "Example";
            userMenuScript.Command         = "c:\\windows\\system32\\calc.exe";
            userMenuScript.Arguments       = "";
            userMenuScript.AskConfirmation = false;
            userMenuScript.OnEvent         = ScriptEvent.ShowInUserMenuBar;
            userMenuScript.AddToRevisionGridContextMenu = false;
            userMenuScript.Enabled = false;
            Scripts.Add(userMenuScript);
        }
コード例 #2
0
        private static void AddDefaultScripts()
        {
            ScriptInfo fetchAfterCommitScript = new ScriptInfo();

            fetchAfterCommitScript.Name            = "Fetch changes after commit";
            fetchAfterCommitScript.Command         = "git";
            fetchAfterCommitScript.Arguments       = "fetch";
            fetchAfterCommitScript.AskConfirmation = true;
            fetchAfterCommitScript.OnEvent         = ScriptEvent.AfterCommit;
            fetchAfterCommitScript.AddToRevisionGridContextMenu = false;
            fetchAfterCommitScript.Enabled = false;
            Scripts.Add(fetchAfterCommitScript);

            ScriptInfo updateSubmodulesAfterPullScript = new ScriptInfo();

            updateSubmodulesAfterPullScript.Name            = "Update submodules after pull";
            updateSubmodulesAfterPullScript.Command         = "git";
            updateSubmodulesAfterPullScript.Arguments       = "submodule update";
            updateSubmodulesAfterPullScript.AskConfirmation = true;
            updateSubmodulesAfterPullScript.OnEvent         = ScriptEvent.AfterPull;
            updateSubmodulesAfterPullScript.AddToRevisionGridContextMenu = false;
            updateSubmodulesAfterPullScript.Enabled = false;
            Scripts.Add(updateSubmodulesAfterPullScript);
        }
コード例 #3
0
        private static CommandStatus RunScript(IWin32Window owner, GitModule module, ScriptInfo scriptInfo, IGitUICommands uiCommands, RevisionGridControl revisionGrid)
        {
            if (scriptInfo.AskConfirmation && MessageBox.Show(owner, $"Do you want to execute '{scriptInfo.Name}'?", "Script", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return(false);
            }

            string originalCommand = scriptInfo.Command;

            (string argument, bool abort) = ScriptOptionsParser.Parse(scriptInfo.Arguments, module, owner, revisionGrid);
            if (abort)
            {
                return(false);
            }

            string command = OverrideCommandWhenNecessary(originalCommand);

            command = ExpandCommandVariables(command, module);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, module.WorkingDir, scriptInfo.RunInBackground);
                return(new CommandStatus(true, false));
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, "");
                foreach (var plugin in PluginRegistry.Plugins)
                {
                    if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                    {
                        var eventArgs = new GitUIEventArgs(owner, uiCommands);
                        return(new CommandStatus(true, plugin.Execute(eventArgs)));
                    }
                }

                return(false);
            }

            if (command.StartsWith(NavigateToPrefix))
            {
                if (revisionGrid == null)
                {
                    return(false);
                }

                command = command.Replace(NavigateToPrefix, string.Empty);
                if (!command.IsNullOrEmpty())
                {
                    var revisionRef = new Executable(command, module.WorkingDir).GetOutputLines(argument).FirstOrDefault();

                    if (revisionRef != null)
                    {
                        revisionGrid.GoToRef(revisionRef, true);
                    }
                }

                return(new CommandStatus(true, false));
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowStandardProcessDialog(owner, command, argument, module.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    new Executable(command, module.WorkingDir).Start(argument);
                }
            }

            return(new CommandStatus(true, !scriptInfo.RunInBackground));
        }
コード例 #4
0
        internal static void RunScript(ScriptInfo scriptInfo, RevisionGrid RevisionGrid)
        {
            string command  = scriptInfo.Command;
            string argument = scriptInfo.Arguments;

            command = OverrideCommandWhenNecessary(command);

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <GitHead>();
            var selectedRemoteBranches = new List <GitHead>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <GitHead>();
            var selectedTags           = new List <GitHead>();
            var currentLocalBranches   = new List <GitHead>();
            var currentRemoteBranches  = new List <GitHead>();
            var currentBranches        = new List <GitHead>();
            var currentTags            = new List <GitHead>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                {
                    continue;
                }
                if (!option.StartsWith("{s") || selectedRevision != null)
                {
                    currentRevision = GetCurrentRevision(RevisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision, option);
                }
                else
                {
                    selectedRevision = CalculateSelectedRevision(RevisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                switch (option)
                {
                case "{sTag}":
                    if (selectedTags.Count == 1)
                    {
                        argument = argument.Replace(option, selectedTags[0].Name);
                    }
                    else if (selectedTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sBranch}":
                    if (selectedBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedBranches[0].Name);
                    }
                    else if (selectedBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedBranches, "Selected Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sLocalBranch}":
                    if (selectedLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedLocalBranches[0].Name);
                    }
                    else if (selectedLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedLocalBranches,
                                                                 "Selected Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemoteBranch}":
                    if (selectedRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                    }
                    else if (selectedRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedRemoteBranches,
                                                                 "Selected Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemote}":
                    if (selectedRemotes.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemotes[0]);
                    }
                    else if (selectedRemotes.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedRemotes, "Selected Revision Remote"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sHash}":
                    argument = argument.Replace(option, selectedRevision.Guid);
                    break;

                case "{sMessage}":
                    argument = argument.Replace(option, selectedRevision.Message);
                    break;

                case "{sAuthor}":
                    argument = argument.Replace(option, selectedRevision.Author);
                    break;

                case "{sCommitter}":
                    argument = argument.Replace(option, selectedRevision.Committer);
                    break;

                case "{sAuthorDate}":
                    argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                    break;

                case "{sCommitDate}":
                    argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                    break;

                case "{cTag}":
                    if (currentTags.Count == 1)
                    {
                        argument = argument.Replace(option, currentTags[0].Name);
                    }
                    else if (currentTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cBranch}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentBranches[0].Name);
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentBranches, "Current Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cLocalBranch}":
                    if (currentLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentLocalBranches[0].Name);
                    }
                    else if (currentLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentLocalBranches,
                                                                 "Current Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cRemoteBranch}":
                    if (currentRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentRemoteBranches[0].Name);
                    }
                    else if (currentRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentRemoteBranches,
                                                                 "Current Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cHash}":
                    argument = argument.Replace(option, currentRevision.Guid);
                    break;

                case "{cMessage}":
                    argument = argument.Replace(option, currentRevision.Message);
                    break;

                case "{cAuthor}":
                    argument = argument.Replace(option, currentRevision.Author);
                    break;

                case "{cCommitter}":
                    argument = argument.Replace(option, currentRevision.Committer);
                    break;

                case "{cAuthorDate}":
                    argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                    break;

                case "{cCommitDate}":
                    argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                    break;

                case "{cDefaultRemote}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option,
                                                    Settings.Module.GetSetting(string.Format("branch.{0}.remote",
                                                                                             currentBranches[0].Name)));
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    Settings.Module.GetSetting(string.Format("branch.{0}.remote",
                                                                                             askToSpecify(
                                                                                                 currentBranches,
                                                                                                 "Current Revision Branch"))));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{UserInput}":
                    SimplePrompt Prompt = new SimplePrompt();
                    Prompt.ShowDialog();
                    argument = argument.Replace(option, Prompt.UserInput);
                    break;
                }
            }

            new FormProcess(command, argument).ShowDialog();
        }
コード例 #5
0
ファイル: RunScript.cs プロジェクト: tekmaven/gitextensions
        public static void RunScript(string script, RevisionGrid RevisionGrid)
        {
            if (string.IsNullOrEmpty(script))
            {
                return;
            }

            ScriptInfo scriptInfo = ScriptManager.GetScript(script);
            string     command;
            string     argument;

            if (scriptInfo == null)
            {
                MessageBox.Show("Cannot find script: " + script, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                command  = scriptInfo.Command;
                argument = scriptInfo.Arguments;
            }


            if (string.IsNullOrEmpty(command))
            {
                return;
            }

            //Make sure we are able to run git, even if git is not in the path
            if (command.Equals("git", System.StringComparison.CurrentCultureIgnoreCase) ||
                command.Equals("{git}", System.StringComparison.CurrentCultureIgnoreCase))
            {
                command = Settings.GitCommand;
            }

            if (command.Equals("gitextensions", System.StringComparison.CurrentCultureIgnoreCase) ||
                command.Equals("{gitextensions}", System.StringComparison.CurrentCultureIgnoreCase) ||
                command.Equals("gitex", System.StringComparison.CurrentCultureIgnoreCase) ||
                command.Equals("{gitex}", System.StringComparison.CurrentCultureIgnoreCase))
            {
                command = Settings.GetGitExtensionsFullPath();
            }

            string[] options =
            {
                "{sTag}",
                "{sBranch}",
                "{sLocalBranch}",
                "{sRemoteBranch}",
                "{sRemote}",
                "{sHash}",
                "{sMessage}",
                "{sAuthor}",
                "{sCommitter}",
                "{sAuthorDate}",
                "{sCommitDate}",
                "{cTag}",
                "{cBranch}",
                "{cLocalBranch}",
                "{cRemoteBranch}",
                "{cHash}",
                "{cMessage}",
                "{cAuthor}",
                "{cCommitter}",
                "{cAuthorDate}",
                "{cCommitDate}",
                "{cDefaultRemote}",
                "{UserInput}"
            };

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <GitHead>();
            var selectedRemoteBranches = new List <GitHead>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <GitHead>();
            var selectedTags           = new List <GitHead>();
            var currentLocalBranches   = new List <GitHead>();
            var currentRemoteBranches  = new List <GitHead>();
            var currentBranches        = new List <GitHead>();
            var currentTags            = new List <GitHead>();

            foreach (string option in options)
            {
                if (!string.IsNullOrEmpty(argument) && argument.Contains(option))
                {
                    if (option.StartsWith("{s") && selectedRevision == null)
                    {
                        if (RevisionGrid == null)
                        {
                            MessageBox.Show(string.Format("Option {0} is only supported when started from revision grid.", option), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        selectedRevision = RevisionGrid.GetRevision(RevisionGrid.LastRow);
                        foreach (GitHead head in selectedRevision.Heads)
                        {
                            if (head.IsTag)
                            {
                                selectedTags.Add(head);
                            }

                            else if (head.IsHead || head.IsRemote)
                            {
                                selectedBranches.Add(head);
                                if (head.IsRemote)
                                {
                                    selectedRemoteBranches.Add(head);
                                    if (!selectedRemotes.Contains(head.Remote))
                                    {
                                        selectedRemotes.Add(head.Remote);
                                    }
                                }
                                else
                                {
                                    selectedLocalBranches.Add(head);
                                }
                            }
                        }
                    }
                    else if (option.StartsWith("{c") && currentRevision == null)
                    {
                        IList <GitHead> heads;

                        if (RevisionGrid == null)
                        {
                            heads = new List <GitHead>();
                            string currentRevisionGuid = Settings.Module.GetCurrentCheckout();
                            foreach (GitHead head in Settings.Module.GetHeads(true, true))
                            {
                                if (head.Guid == currentRevisionGuid)
                                {
                                    heads.Add(head);
                                }
                            }
                        }
                        else
                        {
                            currentRevision = RevisionGrid.GetCurrentRevision();
                            heads           = currentRevision.Heads;
                        }

                        foreach (GitHead head in heads)
                        {
                            if (head.IsTag)
                            {
                                currentTags.Add(head);
                            }
                            else if (head.IsHead || head.IsRemote)
                            {
                                currentBranches.Add(head);
                                if (head.IsRemote)
                                {
                                    currentRemoteBranches.Add(head);
                                }
                                else
                                {
                                    currentLocalBranches.Add(head);
                                }
                            }
                        }
                    }

                    switch (option)
                    {
                    case "{sTag}":
                        if (selectedTags.Count == 1)
                        {
                            argument = argument.Replace(option, selectedTags[0].Name);
                        }
                        else if (selectedTags.Count != 0)
                        {
                            argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{sBranch}":
                        if (selectedBranches.Count == 1)
                        {
                            argument = argument.Replace(option, selectedBranches[0].Name);
                        }
                        else if (selectedBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedBranches, "Selected Revision Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{sLocalBranch}":
                        if (selectedLocalBranches.Count == 1)
                        {
                            argument = argument.Replace(option, selectedLocalBranches[0].Name);
                        }
                        else if (selectedLocalBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedLocalBranches,
                                                                     "Selected Revision Local Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{sRemoteBranch}":
                        if (selectedRemoteBranches.Count == 1)
                        {
                            argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                        }
                        else if (selectedRemoteBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedRemoteBranches,
                                                                     "Selected Revision Remote Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{sRemote}":
                        if (selectedRemotes.Count == 1)
                        {
                            argument = argument.Replace(option, selectedRemotes[0]);
                        }
                        else if (selectedRemotes.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedRemotes, "Selected Revision Remote"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{sHash}":
                        argument = argument.Replace(option, selectedRevision.Guid);
                        break;

                    case "{sMessage}":
                        argument = argument.Replace(option, selectedRevision.Message);
                        break;

                    case "{sAuthor}":
                        argument = argument.Replace(option, selectedRevision.Author);
                        break;

                    case "{sCommitter}":
                        argument = argument.Replace(option, selectedRevision.Committer);
                        break;

                    case "{sAuthorDate}":
                        argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                        break;

                    case "{sCommitDate}":
                        argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                        break;

                    case "{cTag}":
                        if (currentTags.Count == 1)
                        {
                            argument = argument.Replace(option, currentTags[0].Name);
                        }
                        else if (currentTags.Count != 0)
                        {
                            argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{cBranch}":
                        if (currentBranches.Count == 1)
                        {
                            argument = argument.Replace(option, currentBranches[0].Name);
                        }
                        else if (currentBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(currentBranches, "Current Revision Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{cLocalBranch}":
                        if (currentLocalBranches.Count == 1)
                        {
                            argument = argument.Replace(option, currentLocalBranches[0].Name);
                        }
                        else if (currentLocalBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(currentLocalBranches,
                                                                     "Current Revision Local Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{cRemoteBranch}":
                        if (currentRemoteBranches.Count == 1)
                        {
                            argument = argument.Replace(option, currentRemoteBranches[0].Name);
                        }
                        else if (currentRemoteBranches.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(currentRemoteBranches,
                                                                     "Current Revision Remote Branch"));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{cHash}":
                        argument = argument.Replace(option, currentRevision.Guid);
                        break;

                    case "{cMessage}":
                        argument = argument.Replace(option, currentRevision.Message);
                        break;

                    case "{cAuthor}":
                        argument = argument.Replace(option, currentRevision.Author);
                        break;

                    case "{cCommitter}":
                        argument = argument.Replace(option, currentRevision.Committer);
                        break;

                    case "{cAuthorDate}":
                        argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                        break;

                    case "{cCommitDate}":
                        argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                        break;

                    case "{cDefaultRemote}":
                        if (currentBranches.Count == 1)
                        {
                            argument = argument.Replace(option, Settings.Module.GetSetting(string.Format("branch.{0}.remote", currentBranches[0].Name)));
                        }
                        else if (currentBranches.Count != 0)
                        {
                            argument = argument.Replace(option, Settings.Module.GetSetting(string.Format("branch.{0}.remote",
                                                                                                         askToSpecify(currentBranches, "Current Revision Branch"))));
                        }
                        else
                        {
                            argument = argument.Replace(option, "");
                        }
                        break;

                    case "{UserInput}":
                        SimplePrompt Prompt = new SimplePrompt();
                        Prompt.ShowDialog();
                        argument = argument.Replace(option, Prompt.UserInput);
                        break;

                    default:
                        break;
                    }
                }
            }

            new FormProcess(command, argument).ShowDialog();
        }
コード例 #6
0
        internal static void RunScript(ScriptInfo scriptInfo, RevisionGrid RevisionGrid)
        {
            string command = scriptInfo.Command;
            string argument = scriptInfo.Arguments;

            command = OverrideCommandWhenNecessary(command);

            GitRevision selectedRevision = null;
            GitRevision currentRevision = null;

            var selectedLocalBranches = new List<GitHead>();
            var selectedRemoteBranches = new List<GitHead>();
            var selectedRemotes = new List<string>();
            var selectedBranches = new List<GitHead>();
            var selectedTags = new List<GitHead>();
            var currentLocalBranches = new List<GitHead>();
            var currentRemoteBranches = new List<GitHead>();
            var currentBranches = new List<GitHead>();
            var currentTags = new List<GitHead>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                    continue;
                if (!option.StartsWith("{s") || selectedRevision != null)
                {
                    currentRevision = GetCurrentRevision(RevisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision, option);
                }
                else
                {
                    selectedRevision = CalculateSelectedRevision(RevisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                switch (option)
                {
                    case "{sTag}":
                        if (selectedTags.Count == 1)
                            argument = argument.Replace(option, selectedTags[0].Name);
                        else if (selectedTags.Count != 0)
                            argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sBranch}":
                        if (selectedBranches.Count == 1)
                            argument = argument.Replace(option, selectedBranches[0].Name);
                        else if (selectedBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedBranches, "Selected Revision Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sLocalBranch}":
                        if (selectedLocalBranches.Count == 1)
                            argument = argument.Replace(option, selectedLocalBranches[0].Name);
                        else if (selectedLocalBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedLocalBranches,
                                                                     "Selected Revision Local Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sRemoteBranch}":
                        if (selectedRemoteBranches.Count == 1)
                            argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                        else if (selectedRemoteBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedRemoteBranches,
                                                                     "Selected Revision Remote Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sRemote}":
                        if (selectedRemotes.Count == 1)
                            argument = argument.Replace(option, selectedRemotes[0]);
                        else if (selectedRemotes.Count != 0)
                        {
                            argument = argument.Replace(option,
                                                        askToSpecify(selectedRemotes, "Selected Revision Remote"));
                        }
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{sHash}":
                        argument = argument.Replace(option, selectedRevision.Guid);
                        break;
                    case "{sMessage}":
                        argument = argument.Replace(option, selectedRevision.Message);
                        break;
                    case "{sAuthor}":
                        argument = argument.Replace(option, selectedRevision.Author);
                        break;
                    case "{sCommitter}":
                        argument = argument.Replace(option, selectedRevision.Committer);
                        break;
                    case "{sAuthorDate}":
                        argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                        break;
                    case "{sCommitDate}":
                        argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                        break;
                    case "{cTag}":
                        if (currentTags.Count == 1)
                            argument = argument.Replace(option, currentTags[0].Name);
                        else if (currentTags.Count != 0)
                            argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cBranch}":
                        if (currentBranches.Count == 1)
                            argument = argument.Replace(option, currentBranches[0].Name);
                        else if (currentBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentBranches, "Current Revision Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cLocalBranch}":
                        if (currentLocalBranches.Count == 1)
                            argument = argument.Replace(option, currentLocalBranches[0].Name);
                        else if (currentLocalBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentLocalBranches,
                                                                     "Current Revision Local Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cRemoteBranch}":
                        if (currentRemoteBranches.Count == 1)
                            argument = argument.Replace(option, currentRemoteBranches[0].Name);
                        else if (currentRemoteBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        askToSpecify(currentRemoteBranches,
                                                                     "Current Revision Remote Branch"));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{cHash}":
                        argument = argument.Replace(option, currentRevision.Guid);
                        break;
                    case "{cMessage}":
                        argument = argument.Replace(option, currentRevision.Message);
                        break;
                    case "{cAuthor}":
                        argument = argument.Replace(option, currentRevision.Author);
                        break;
                    case "{cCommitter}":
                        argument = argument.Replace(option, currentRevision.Committer);
                        break;
                    case "{cAuthorDate}":
                        argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                        break;
                    case "{cCommitDate}":
                        argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                        break;
                    case "{cDefaultRemote}":
                        if (currentBranches.Count == 1)
                            argument = argument.Replace(option,
                                                        Settings.Module.GetSetting(string.Format("branch.{0}.remote",
                                                                                                 currentBranches[0].Name)));
                        else if (currentBranches.Count != 0)
                            argument = argument.Replace(option,
                                                        Settings.Module.GetSetting(string.Format("branch.{0}.remote",
                                                                                                 askToSpecify(
                                                                                                     currentBranches,
                                                                                                     "Current Revision Branch"))));
                        else
                            argument = argument.Replace(option, "");
                        break;
                    case "{UserInput}":
                        SimplePrompt Prompt = new SimplePrompt();
                        Prompt.ShowDialog();
                        argument = argument.Replace(option, Prompt.UserInput);
                        break;
                }
            }

            new FormProcess(command, argument).ShowDialog();
        }
コード例 #7
0
        private static void AddDefaultScripts()
        {
            ScriptInfo fetchAfterCommitScript = new ScriptInfo();

            fetchAfterCommitScript.HotkeyCommandIdentifier = 9000;
            fetchAfterCommitScript.Name            = "Fetch changes after commit";
            fetchAfterCommitScript.Command         = "git";
            fetchAfterCommitScript.Arguments       = "fetch";
            fetchAfterCommitScript.RunInBackground = false;
            fetchAfterCommitScript.AskConfirmation = true;
            fetchAfterCommitScript.OnEvent         = ScriptEvent.AfterCommit;
            fetchAfterCommitScript.AddToRevisionGridContextMenu = false;
            fetchAfterCommitScript.Enabled = false;
            Scripts.Add(fetchAfterCommitScript);

            ScriptInfo updateSubmodulesAfterPullScript = new ScriptInfo();

            updateSubmodulesAfterPullScript.HotkeyCommandIdentifier = 9001;
            updateSubmodulesAfterPullScript.Name            = "Update submodules after pull";
            updateSubmodulesAfterPullScript.Command         = "git";
            updateSubmodulesAfterPullScript.Arguments       = "submodule update --init --recursive";
            updateSubmodulesAfterPullScript.RunInBackground = false;
            updateSubmodulesAfterPullScript.AskConfirmation = true;
            updateSubmodulesAfterPullScript.OnEvent         = ScriptEvent.AfterPull;
            updateSubmodulesAfterPullScript.AddToRevisionGridContextMenu = false;
            updateSubmodulesAfterPullScript.Enabled = false;
            Scripts.Add(updateSubmodulesAfterPullScript);

            ScriptInfo userMenuScript = new ScriptInfo();

            userMenuScript.HotkeyCommandIdentifier = 9002;
            userMenuScript.Name            = "Example";
            userMenuScript.Command         = "c:\\windows\\system32\\calc.exe";
            userMenuScript.Arguments       = "";
            userMenuScript.RunInBackground = false;
            userMenuScript.AskConfirmation = false;
            userMenuScript.OnEvent         = ScriptEvent.ShowInUserMenuBar;
            userMenuScript.AddToRevisionGridContextMenu = false;
            userMenuScript.Enabled = false;
            Scripts.Add(userMenuScript);

            ScriptInfo openHashOnGitHub = new ScriptInfo();

            openHashOnGitHub.HotkeyCommandIdentifier = 9003;
            openHashOnGitHub.Name            = "Open on GitHub";
            openHashOnGitHub.Command         = "{openurl}";
            openHashOnGitHub.Arguments       = "https://github.com{cDefaultRemotePathFromUrl}/commit/{sHash}";
            openHashOnGitHub.RunInBackground = false;
            openHashOnGitHub.AskConfirmation = false;
            openHashOnGitHub.OnEvent         = 0;
            openHashOnGitHub.AddToRevisionGridContextMenu = true;
            openHashOnGitHub.Enabled = false;
            Scripts.Add(openHashOnGitHub);

            ScriptInfo FetchAll = new ScriptInfo();

            FetchAll.HotkeyCommandIdentifier = 9004;
            FetchAll.Name            = "Fetch All Submodules";
            FetchAll.Command         = "git";
            FetchAll.Arguments       = "submodule foreach --recursive git fetch --all";
            FetchAll.RunInBackground = false;
            FetchAll.AskConfirmation = false;
            FetchAll.OnEvent         = 0;
            FetchAll.AddToRevisionGridContextMenu = true;
            FetchAll.Enabled = false;
            Scripts.Add(FetchAll);
        }
コード例 #8
0
        internal static bool RunScript(IWin32Window owner, GitModule aModule, ScriptInfo scriptInfo, RevisionGrid revisionGrid)
        {
            string originalCommand = scriptInfo.Command;
            string argument        = scriptInfo.Arguments;

            string command = OverrideCommandWhenNecessary(originalCommand);
            var    allSelectedRevisions = new List <GitRevision>();

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <IGitRef>();
            var selectedRemoteBranches = new List <IGitRef>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <IGitRef>();
            var selectedTags           = new List <IGitRef>();
            var currentLocalBranches   = new List <IGitRef>();
            var currentRemoteBranches  = new List <IGitRef>();
            var currentRemote          = "";
            var currentBranches        = new List <IGitRef>();
            var currentTags            = new List <IGitRef>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                {
                    continue;
                }
                if (option.StartsWith("{c") && currentRevision == null)
                {
                    currentRevision = GetCurrentRevision(aModule, revisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision);

                    if (currentLocalBranches.Count == 1)
                    {
                        currentRemote = aModule.GetSetting(string.Format(SettingKeyString.BranchRemote, currentLocalBranches[0].Name));
                    }
                    else
                    {
                        currentRemote = aModule.GetCurrentRemote();
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            currentRemote = aModule.GetSetting(string.Format(SettingKeyString.BranchRemote,
                                                                             askToSpecify(currentLocalBranches, "Current Revision Branch")));
                        }
                    }
                }
                else if (option.StartsWith("{s") && selectedRevision == null && revisionGrid != null)
                {
                    allSelectedRevisions = revisionGrid.GetSelectedRevisions();
                    allSelectedRevisions.Reverse(); // Put first clicked revisions first
                    selectedRevision = CalculateSelectedRevision(revisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                string remote;
                string url;
                switch (option)
                {
                case "{sHashes}":
                    argument = argument.Replace(option,
                                                string.Join(" ", allSelectedRevisions.Select(revision => revision.Guid).ToArray()));
                    break;

                case "{sTag}":
                    if (selectedTags.Count == 1)
                    {
                        argument = argument.Replace(option, selectedTags[0].Name);
                    }
                    else if (selectedTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sBranch}":
                    if (selectedBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedBranches[0].Name);
                    }
                    else if (selectedBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedBranches, "Selected Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sLocalBranch}":
                    if (selectedLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedLocalBranches[0].Name);
                    }
                    else if (selectedLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedLocalBranches,
                                                                 "Selected Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemoteBranch}":
                    if (selectedRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                    }
                    else if (selectedRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedRemoteBranches,
                                                                 "Selected Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemote}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    argument = argument.Replace(option, remote);
                    break;

                case "{sRemoteUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, url);
                    break;

                case "{sRemotePathFromUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{sHash}":
                    argument = argument.Replace(option, selectedRevision.Guid);
                    break;

                case "{sMessage}":
                    argument = argument.Replace(option, selectedRevision.Subject);
                    break;

                case "{sAuthor}":
                    argument = argument.Replace(option, selectedRevision.Author);
                    break;

                case "{sCommitter}":
                    argument = argument.Replace(option, selectedRevision.Committer);
                    break;

                case "{sAuthorDate}":
                    argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                    break;

                case "{sCommitDate}":
                    argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                    break;

                case "{cTag}":
                    if (currentTags.Count == 1)
                    {
                        argument = argument.Replace(option, currentTags[0].Name);
                    }
                    else if (currentTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cBranch}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentBranches[0].Name);
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentBranches, "Current Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cLocalBranch}":
                    if (currentLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentLocalBranches[0].Name);
                    }
                    else if (currentLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentLocalBranches,
                                                                 "Current Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cRemoteBranch}":
                    if (currentRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentRemoteBranches[0].Name);
                    }
                    else if (currentRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentRemoteBranches,
                                                                 "Current Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cHash}":
                    argument = argument.Replace(option, currentRevision.Guid);
                    break;

                case "{cMessage}":
                    argument = argument.Replace(option, currentRevision.Subject);
                    break;

                case "{cAuthor}":
                    argument = argument.Replace(option, currentRevision.Author);
                    break;

                case "{cCommitter}":
                    argument = argument.Replace(option, currentRevision.Committer);
                    break;

                case "{cAuthorDate}":
                    argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                    break;

                case "{cCommitDate}":
                    argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                    break;

                case "{cDefaultRemote}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    argument = argument.Replace(option, currentRemote);
                    break;

                case "{cDefaultRemoteUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, url);
                    break;

                case "{cDefaultRemotePathFromUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{UserInput}":
                    using (SimplePrompt Prompt = new SimplePrompt())
                    {
                        Prompt.ShowDialog();
                        argument = argument.Replace(option, Prompt.UserInput);
                    }
                    break;

                case "{WorkingDir}":
                    argument = argument.Replace(option, aModule.WorkingDir);
                    break;
                }
            }
            command = ExpandCommandVariables(command, aModule);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, aModule.WorkingDir, scriptInfo.RunInBackground);
                return(false);
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, "");
                foreach (var plugin in Plugin.LoadedPlugins.Plugins)
                {
                    if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                    {
                        var eventArgs = new GitUIEventArgs(owner, revisionGrid.UICommands, argument);
                        return(plugin.Execute(eventArgs));
                    }
                }
                return(false);
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowStandardProcessDialog(owner, command, argument, aModule.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    aModule.RunExternalCmdDetached(command, argument);
                }
            }

            return(!scriptInfo.RunInBackground);
        }
コード例 #9
0
        private static bool RunScript(IWin32Window owner, GitModule module, ScriptInfo scriptInfo, RevisionGridControl revisionGrid)
        {
            if (scriptInfo.AskConfirmation && MessageBox.Show(owner, $"Do you want to execute '{scriptInfo.Name}'?", "Script", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return(false);
            }

            string originalCommand = scriptInfo.Command;
            string argument        = scriptInfo.Arguments;

            string command = OverrideCommandWhenNecessary(originalCommand);
            IReadOnlyList <GitRevision> allSelectedRevisions = Array.Empty <GitRevision>();

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <IGitRef>();
            var selectedRemoteBranches = new List <IGitRef>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <IGitRef>();
            var selectedTags           = new List <IGitRef>();
            var currentLocalBranches   = new List <IGitRef>();
            var currentRemoteBranches  = new List <IGitRef>();
            var currentRemote          = "";
            var currentBranches        = new List <IGitRef>();
            var currentTags            = new List <IGitRef>();

            foreach (string option in _options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                {
                    continue;
                }

                if (option.StartsWith("{c") && currentRevision == null)
                {
                    currentRevision = GetCurrentRevision(module, revisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision);

                    if (currentLocalBranches.Count == 1)
                    {
                        currentRemote = module.GetSetting(string.Format(SettingKeyString.BranchRemote, currentLocalBranches[0].Name));
                    }
                    else
                    {
                        currentRemote = module.GetCurrentRemote();
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            currentRemote = module.GetSetting(string.Format(SettingKeyString.BranchRemote,
                                                                            AskToSpecify(currentLocalBranches, "Current Revision Branch")));
                        }
                    }
                }
                else if (option.StartsWith("{s") && selectedRevision == null && revisionGrid != null)
                {
                    allSelectedRevisions = revisionGrid.GetSelectedRevisions();
                    selectedRevision     = CalculateSelectedRevision(revisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                string remote;
                string url;
                switch (option)
                {
                case "{sHashes}":
                    argument = argument.Replace(option,
                                                string.Join(" ", allSelectedRevisions.Select(revision => revision.Guid).ToArray()));
                    break;

                case "{sTag}":
                    if (selectedTags.Count == 1)
                    {
                        argument = argument.Replace(option, selectedTags[0].Name);
                    }
                    else if (selectedTags.Count != 0)
                    {
                        argument = argument.Replace(option, AskToSpecify(selectedTags, "Selected Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{sBranch}":
                    if (selectedBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedBranches[0].Name);
                    }
                    else if (selectedBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(selectedBranches, "Selected Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{sLocalBranch}":
                    if (selectedLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedLocalBranches[0].Name);
                    }
                    else if (selectedLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(selectedLocalBranches,
                                                                 "Selected Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{sRemoteBranch}":
                    if (selectedRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                    }
                    else if (selectedRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(selectedRemoteBranches,
                                                                 "Selected Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{sRemote}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    remote = selectedRemotes.Count == 1
                            ? selectedRemotes[0]
                            : AskToSpecify(selectedRemotes, "Selected Revision Remote");

                    argument = argument.Replace(option, remote);
                    break;

                case "{sRemoteUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    remote = selectedRemotes.Count == 1
                            ? selectedRemotes[0]
                            : AskToSpecify(selectedRemotes, "Selected Revision Remote");

                    url      = module.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, url);
                    break;

                case "{sRemotePathFromUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    remote = selectedRemotes.Count == 1
                            ? selectedRemotes[0]
                            : AskToSpecify(selectedRemotes, "Selected Revision Remote");

                    url      = module.GetSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{sHash}":
                    argument = argument.Replace(option, selectedRevision.Guid);
                    break;

                case "{sMessage}":
                    argument = argument.Replace(option, selectedRevision.Subject);
                    break;

                case "{sAuthor}":
                    argument = argument.Replace(option, selectedRevision.Author);
                    break;

                case "{sCommitter}":
                    argument = argument.Replace(option, selectedRevision.Committer);
                    break;

                case "{sAuthorDate}":
                    argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                    break;

                case "{sCommitDate}":
                    argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                    break;

                case "{cTag}":
                    if (currentTags.Count == 1)
                    {
                        argument = argument.Replace(option, currentTags[0].Name);
                    }
                    else if (currentTags.Count != 0)
                    {
                        argument = argument.Replace(option, AskToSpecify(currentTags, "Current Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{cBranch}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentBranches[0].Name);
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(currentBranches, "Current Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{cLocalBranch}":
                    if (currentLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentLocalBranches[0].Name);
                    }
                    else if (currentLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(currentLocalBranches,
                                                                 "Current Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{cRemoteBranch}":
                    if (currentRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentRemoteBranches[0].Name);
                    }
                    else if (currentRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    AskToSpecify(currentRemoteBranches,
                                                                 "Current Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }

                    break;

                case "{cHash}":
                    argument = argument.Replace(option, currentRevision.Guid);
                    break;

                case "{cMessage}":
                    argument = argument.Replace(option, currentRevision.Subject);
                    break;

                case "{cAuthor}":
                    argument = argument.Replace(option, currentRevision.Author);
                    break;

                case "{cCommitter}":
                    argument = argument.Replace(option, currentRevision.Committer);
                    break;

                case "{cAuthorDate}":
                    argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                    break;

                case "{cCommitDate}":
                    argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                    break;

                case "{cDefaultRemote}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    argument = argument.Replace(option, currentRemote);
                    break;

                case "{cDefaultRemoteUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    url      = module.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, url);
                    break;

                case "{cDefaultRemotePathFromUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }

                    url      = module.GetSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{UserInput}":
                    using (var prompt = new SimplePrompt())
                    {
                        prompt.ShowDialog();
                        argument = argument.Replace(option, prompt.UserInput);
                    }

                    break;

                case "{UserFiles}":
                    using (FormFilePrompt prompt = new FormFilePrompt())
                    {
                        if (prompt.ShowDialog(owner) != DialogResult.OK)
                        {
                            return(false);
                        }

                        argument = argument.Replace(option, prompt.FileInput);
                        break;
                    }

                case "{WorkingDir}":
                    argument = argument.Replace(option, module.WorkingDir);
                    break;
                }
            }

            command = ExpandCommandVariables(command, module);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, module.WorkingDir, scriptInfo.RunInBackground);
                return(false);
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, "");
                foreach (var plugin in PluginRegistry.Plugins)
                {
                    if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                    {
                        var eventArgs = new GitUIEventArgs(owner, revisionGrid.UICommands);
                        return(plugin.Execute(eventArgs));
                    }
                }

                return(false);
            }

            if (command.StartsWith(NavigateToPrefix))
            {
                command = command.Replace(NavigateToPrefix, string.Empty);
                if (!command.IsNullOrEmpty())
                {
                    var revisionRef = new Executable(command, module.WorkingDir).GetOutputLines(argument).FirstOrDefault();

                    if (revisionRef != null)
                    {
                        revisionGrid.GoToRef(revisionRef, true);
                    }
                }

                return(false);
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowStandardProcessDialog(owner, command, argument, module.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    new Executable(command, module.WorkingDir).Start(argument);
                }
            }

            return(!scriptInfo.RunInBackground);
        }
コード例 #10
0
        private static CommandStatus RunScript(IWin32Window owner, IGitModule module, ScriptInfo scriptInfo, IGitUICommands uiCommands,
                                               RevisionGridControl revisionGrid, Action <string> showError)
        {
            if (scriptInfo.AskConfirmation && MessageBox.Show(owner, $"Do you want to execute '{scriptInfo.Name}'?", "Script", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return(false);
            }

            string originalCommand = scriptInfo.Command;

            (string argument, bool abort) = ScriptOptionsParser.Parse(scriptInfo.Arguments, module, owner, revisionGrid);
            if (abort)
            {
                showError($"There must be a revision in order to substitute the argument option(s) for the script to run.");
                return(false);
            }

            string command = OverrideCommandWhenNecessary(originalCommand);

            command = ExpandCommandVariables(command, module);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, module.WorkingDir, scriptInfo.RunInBackground);

                // 'RunPowerShell' always runs the script detached (yet).
                // Hence currently, it does not make sense to set 'needsGridRefresh' to '!scriptInfo.RunInBackground'.
                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, "");

                lock (PluginRegistry.Plugins)
                {
                    foreach (var plugin in PluginRegistry.Plugins)
                    {
                        if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                        {
                            var eventArgs = new GitUIEventArgs(owner, uiCommands);
                            return(new CommandStatus(executed: true, needsGridRefresh: plugin.Execute(eventArgs)));
                        }
                    }
                }

                return(false);
            }

            if (command.StartsWith(NavigateToPrefix))
            {
                if (revisionGrid == null)
                {
                    return(false);
                }

                command = command.Replace(NavigateToPrefix, string.Empty);
                if (!command.IsNullOrEmpty())
                {
                    var revisionRef = new Executable(command, module.WorkingDir).GetOutputLines(argument).FirstOrDefault();

                    if (revisionRef != null)
                    {
                        revisionGrid.GoToRef(revisionRef, true);
                    }
                }

                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowStandardProcessDialog(owner, command, argument, module.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    new Executable(command, module.WorkingDir).Start(argument);
                }
            }

            return(new CommandStatus(executed: true, needsGridRefresh: !scriptInfo.RunInBackground));
        }
コード例 #11
0
        private static CommandStatus RunScriptInternal(IWin32Window owner, IGitModule module, string scriptKey, IGitUICommands uiCommands,
                                                       RevisionGridControl revisionGrid)
        {
            if (string.IsNullOrEmpty(scriptKey))
            {
                return(false);
            }

            ScriptInfo scriptInfo = ScriptManager.GetScript(scriptKey);

            if (scriptInfo is null)
            {
                ThreadHelper.AssertOnUIThread();
                throw new UserExternalOperationException($"{Strings.ScriptErrorCantFind}: '{scriptKey}'",
                                                         new ExternalOperationException(command: null, arguments: null, module.WorkingDir, innerException: null));
            }

            if (string.IsNullOrEmpty(scriptInfo.Command))
            {
                return(false);
            }

            string arguments = scriptInfo.Arguments;

            if (!string.IsNullOrEmpty(arguments) && revisionGrid is null)
            {
                string optionDependingOnSelectedRevision
                    = ScriptOptionsParser.Options.FirstOrDefault(option => ScriptOptionsParser.DependsOnSelectedRevision(option) &&
                                                                 ScriptOptionsParser.Contains(arguments, option));
                if (optionDependingOnSelectedRevision is object)
                {
                    ThreadHelper.AssertOnUIThread();
                    throw new UserExternalOperationException($"{Strings.ScriptText}: '{scriptKey}'{Environment.NewLine}'{optionDependingOnSelectedRevision}' {Strings.ScriptErrorOptionWithoutRevisionGridText}",
                                                             new ExternalOperationException(scriptInfo.Command, arguments, module.WorkingDir, innerException: null));
                }
            }

            if (scriptInfo.AskConfirmation &&
                MessageBox.Show(owner, $"{Strings.ScriptConfirmExecute}: '{scriptInfo.Name}'?", Strings.ScriptText,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return(false);
            }

            string originalCommand = scriptInfo.Command;

            (string argument, bool abort) = ScriptOptionsParser.Parse(scriptInfo.Arguments, module, owner, revisionGrid);
            if (abort)
            {
                ThreadHelper.AssertOnUIThread();
                throw new UserExternalOperationException($"{Strings.ScriptText}: '{scriptKey}'{Environment.NewLine}{Strings.ScriptErrorOptionWithoutRevisionText}",
                                                         new ExternalOperationException(scriptInfo.Command, arguments, module.WorkingDir, innerException: null));
            }

            string command = OverrideCommandWhenNecessary(originalCommand);

            command = ExpandCommandVariables(command, module);

            if (scriptInfo.IsPowerShell)
            {
                PowerShellHelper.RunPowerShell(command, argument, module.WorkingDir, scriptInfo.RunInBackground);

                // 'RunPowerShell' always runs the script detached (yet).
                // Hence currently, it does not make sense to set 'needsGridRefresh' to '!scriptInfo.RunInBackground'.
                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (command.StartsWith(PluginPrefix))
            {
                command = command.Replace(PluginPrefix, string.Empty);

                lock (PluginRegistry.Plugins)
                {
                    foreach (var plugin in PluginRegistry.Plugins)
                    {
                        if (plugin.Description.ToLower().Equals(command, StringComparison.CurrentCultureIgnoreCase))
                        {
                            var eventArgs = new GitUIEventArgs(owner, uiCommands);
                            return(new CommandStatus(executed: true, needsGridRefresh: plugin.Execute(eventArgs)));
                        }
                    }
                }

                return(false);
            }

            if (command.StartsWith(NavigateToPrefix))
            {
                if (revisionGrid is null)
                {
                    return(false);
                }

                command = command.Replace(NavigateToPrefix, string.Empty);
                if (!string.IsNullOrEmpty(command))
                {
                    var revisionRef = new Executable(command, module.WorkingDir).GetOutputLines(argument).FirstOrDefault();

                    if (revisionRef != null)
                    {
                        revisionGrid.GoToRef(revisionRef, true);
                    }
                }

                return(new CommandStatus(executed: true, needsGridRefresh: false));
            }

            if (!scriptInfo.RunInBackground)
            {
                FormProcess.ShowDialog(owner, command, argument, module.WorkingDir, null, true);
            }
            else
            {
                if (originalCommand.Equals("{openurl}", StringComparison.CurrentCultureIgnoreCase))
                {
                    Process.Start(argument);
                }
                else
                {
                    // It is totally valid to have a command without an argument, e.g.:
                    //    Command  : myscript.cmd
                    //    Arguments: <blank>
                    new Executable(command, module.WorkingDir).Start(argument ?? string.Empty);
                }
            }

            return(new CommandStatus(executed: true, needsGridRefresh: !scriptInfo.RunInBackground));
        }
コード例 #12
0
        internal static void RunScript(IWin32Window owner, GitModule aModule, ScriptInfo scriptInfo, RevisionGrid revisionGrid)
        {
            string command  = scriptInfo.Command;
            string argument = scriptInfo.Arguments;

            command = OverrideCommandWhenNecessary(command);

            GitRevision selectedRevision = null;
            GitRevision currentRevision  = null;

            var selectedLocalBranches  = new List <GitRef>();
            var selectedRemoteBranches = new List <GitRef>();
            var selectedRemotes        = new List <string>();
            var selectedBranches       = new List <GitRef>();
            var selectedTags           = new List <GitRef>();
            var currentLocalBranches   = new List <GitRef>();
            var currentRemoteBranches  = new List <GitRef>();
            var currentRemote          = "";
            var currentBranches        = new List <GitRef>();
            var currentTags            = new List <GitRef>();

            foreach (string option in Options)
            {
                if (string.IsNullOrEmpty(argument) || !argument.Contains(option))
                {
                    continue;
                }
                if (!option.StartsWith("{s") || selectedRevision != null)
                {
                    currentRevision = GetCurrentRevision(aModule, revisionGrid, currentTags, currentLocalBranches, currentRemoteBranches, currentBranches, currentRevision, option);

                    if (currentLocalBranches.Count == 1)
                    {
                        currentRemote = aModule.GetSetting(string.Format("branch.{0}.remote", currentLocalBranches[0].Name));
                    }
                    else
                    {
                        currentRemote = aModule.GetCurrentRemote();
                        if (string.IsNullOrEmpty(currentRemote))
                        {
                            currentRemote = aModule.GetSetting(string.Format("branch.{0}.remote",
                                                                             askToSpecify(currentLocalBranches, "Current Revision Branch")));
                        }
                    }
                }
                else
                {
                    selectedRevision = CalculateSelectedRevision(revisionGrid, selectedRemoteBranches, selectedRemotes, selectedLocalBranches, selectedBranches, selectedTags);
                }

                string remote;
                string url;
                switch (option)
                {
                case "{sTag}":
                    if (selectedTags.Count == 1)
                    {
                        argument = argument.Replace(option, selectedTags[0].Name);
                    }
                    else if (selectedTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(selectedTags, "Selected Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sBranch}":
                    if (selectedBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedBranches[0].Name);
                    }
                    else if (selectedBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedBranches, "Selected Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sLocalBranch}":
                    if (selectedLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedLocalBranches[0].Name);
                    }
                    else if (selectedLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedLocalBranches,
                                                                 "Selected Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemoteBranch}":
                    if (selectedRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, selectedRemoteBranches[0].Name);
                    }
                    else if (selectedRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(selectedRemoteBranches,
                                                                 "Selected Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{sRemote}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    argument = argument.Replace(option, remote);
                    break;

                case "{sRemoteUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, url);
                    break;

                case "{sRemotePathFromUrl}":
                    if (selectedRemotes.Count == 0)
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    if (selectedRemotes.Count == 1)
                    {
                        remote = selectedRemotes[0];
                    }
                    else
                    {
                        remote = askToSpecify(selectedRemotes, "Selected Revision Remote");
                    }
                    url      = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, remote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{sHash}":
                    argument = argument.Replace(option, selectedRevision.Guid);
                    break;

                case "{sMessage}":
                    argument = argument.Replace(option, selectedRevision.Message);
                    break;

                case "{sAuthor}":
                    argument = argument.Replace(option, selectedRevision.Author);
                    break;

                case "{sCommitter}":
                    argument = argument.Replace(option, selectedRevision.Committer);
                    break;

                case "{sAuthorDate}":
                    argument = argument.Replace(option, selectedRevision.AuthorDate.ToString());
                    break;

                case "{sCommitDate}":
                    argument = argument.Replace(option, selectedRevision.CommitDate.ToString());
                    break;

                case "{cTag}":
                    if (currentTags.Count == 1)
                    {
                        argument = argument.Replace(option, currentTags[0].Name);
                    }
                    else if (currentTags.Count != 0)
                    {
                        argument = argument.Replace(option, askToSpecify(currentTags, "Current Revision Tag"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cBranch}":
                    if (currentBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentBranches[0].Name);
                    }
                    else if (currentBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentBranches, "Current Revision Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cLocalBranch}":
                    if (currentLocalBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentLocalBranches[0].Name);
                    }
                    else if (currentLocalBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentLocalBranches,
                                                                 "Current Revision Local Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cRemoteBranch}":
                    if (currentRemoteBranches.Count == 1)
                    {
                        argument = argument.Replace(option, currentRemoteBranches[0].Name);
                    }
                    else if (currentRemoteBranches.Count != 0)
                    {
                        argument = argument.Replace(option,
                                                    askToSpecify(currentRemoteBranches,
                                                                 "Current Revision Remote Branch"));
                    }
                    else
                    {
                        argument = argument.Replace(option, "");
                    }
                    break;

                case "{cHash}":
                    argument = argument.Replace(option, currentRevision.Guid);
                    break;

                case "{cMessage}":
                    argument = argument.Replace(option, currentRevision.Message);
                    break;

                case "{cAuthor}":
                    argument = argument.Replace(option, currentRevision.Author);
                    break;

                case "{cCommitter}":
                    argument = argument.Replace(option, currentRevision.Committer);
                    break;

                case "{cAuthorDate}":
                    argument = argument.Replace(option, currentRevision.AuthorDate.ToString());
                    break;

                case "{cCommitDate}":
                    argument = argument.Replace(option, currentRevision.CommitDate.ToString());
                    break;

                case "{cDefaultRemote}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    argument = argument.Replace(option, currentRemote);
                    break;

                case "{cDefaultRemoteUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, url);
                    break;

                case "{cDefaultRemotePathFromUrl}":
                    if (string.IsNullOrEmpty(currentRemote))
                    {
                        argument = argument.Replace(option, "");
                        break;
                    }
                    url      = aModule.GetPathSetting(string.Format(SettingKeyString.RemoteUrl, currentRemote));
                    argument = argument.Replace(option, GetRemotePath(url));
                    break;

                case "{UserInput}":
                    using (SimplePrompt Prompt = new SimplePrompt())
                    {
                        Prompt.ShowDialog();
                        argument = argument.Replace(option, Prompt.UserInput);
                    }
                    break;
                }
            }

            if (scriptInfo.ShowProgress)
            {
                FormProcess.ShowDialog(owner, command, argument, aModule.WorkingDir, null, true);
            }
            else
            {
                aModule.RunExternalCmdDetached(command, argument);
            }
        }