예제 #1
0
        public override bool Execute(GitUIBaseEventArgs eventArgs)
        {
            IGitModule gitUiCommands = eventArgs.GitModule;
            var        ownerForm     = eventArgs.OwnerForm as IWin32Window;

            if (!gitUiCommands.IsValidGitWorkingDir())
            {
                MessageBox.Show(ownerForm, _currentDirectoryIsNotValidGit.Text);
                return(false);
            }

            var pathToGource = GourcePath.ValueOrDefault(Settings);

            if (!string.IsNullOrEmpty(pathToGource))
            {
                if (!File.Exists(pathToGource))
                {
                    if (MessageBox.Show(ownerForm,
                                        string.Format(_resetConfigPath.Text, pathToGource), _gource.Text, MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        Settings.SetValue <string>(GourcePath.Name, GourcePath.DefaultValue, s => s);
                        pathToGource = GourcePath.DefaultValue;
                    }
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (MessageBox.Show(ownerForm, _doYouWantDownloadGource.Text, _download.Text,
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(ownerForm, _cannotFindGource.Text);
                        return(false);
                    }
                    var downloadDir  = Path.GetTempPath();
                    var fileName     = Path.Combine(downloadDir, "gource.zip");
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(string.Format(_bytesDownloaded.Text, downloadSize));
                        Directory.CreateDirectory(Path.Combine(downloadDir, "gource"));
                        UnZipFiles(fileName, Path.Combine(downloadDir, "gource"), true);

                        var newGourcePath = Path.Combine(downloadDir, "gource\\gource.exe");
                        if (File.Exists(newGourcePath))
                        {
                            MessageBox.Show(ownerForm, _gourceDownloadedAndUnzipped.Text);
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(ownerForm, _downloadingFailed.Text);
                    }
                }
            }

            using (var gourceStart = new GourceStart(pathToGource, eventArgs, GourceArguments.ValueOrDefault(Settings)))
            {
                gourceStart.ShowDialog(ownerForm);
                Settings.SetValue <string>(GourceArguments.Name, gourceStart.GourceArguments, s => s);
                Settings.SetValue <string>(GourcePath.Name, gourceStart.PathToGource, s => s);
            }
            return(true);
        }
예제 #2
0
        public override bool Execute(GitUIBaseEventArgs eventArgs)
        {
            IGitModule gitUiCommands = eventArgs.GitModule;
            var        ownerForm     = eventArgs.OwnerForm as IWin32Window;

            if (!gitUiCommands.IsValidGitWorkingDir(gitUiCommands.GitWorkingDir))
            {
                MessageBox.Show(ownerForm, "The current directory is not a valid git repository." + Environment.NewLine +
                                Environment.NewLine + "Gource can be only be started from a valid git repository.");
                return(false);
            }

            var pathToGource = Settings.GetSetting("Path to \"gource\"");

            if (!string.IsNullOrEmpty(pathToGource))
            {
                if (!File.Exists(pathToGource))
                {
                    if (MessageBox.Show(ownerForm,
                                        "Cannot find \"gource\" in the configured path: " + pathToGource +
                                        ".\n\n.Do you want to reset the configured path?", "Gource", MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        Settings.SetSetting("Path to \"gource\"", "");
                        pathToGource = Settings.GetSetting("Path to \"gource\"");
                    }
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (MessageBox.Show(ownerForm,
                                    "There is no path to \"gource\" configured.\n\nDo you want to automaticly download \"gource\"?",
                                    "Download", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(ownerForm,
                                        "Cannot find \"gource\".\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                        return(false);
                    }
                    var downloadDir  = Path.GetTempPath();
                    var fileName     = downloadDir + "\\gource.zip";
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(downloadSize + " bytes downloaded.");
                        Directory.CreateDirectory(downloadDir + "\\gource");
                        UnZipFiles(fileName, downloadDir + "\\gource", true);

                        var newGourcePath = downloadDir + "\\gource\\gource.exe";
                        if (File.Exists(newGourcePath))
                        {
                            Settings.SetSetting("Path to \"gource\"", newGourcePath);
                            MessageBox.Show(ownerForm, "\"gource\" has been downloaded and unzipped.");
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(ownerForm,
                                        "Downloading failed.\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                    }
                }
            }

            using (var gourceStart = new GourceStart(pathToGource, eventArgs,
                                                     Settings.GetSetting("Arguments")))
            {
                gourceStart.ShowDialog(ownerForm);

                Settings.SetSetting("Arguments", gourceStart.GourceArguments);
                Settings.SetSetting("Path to \"gource\"", gourceStart.PathToGource);
            }
            return(false);
        }
예제 #3
0
        public void Execute(GitUIBaseEventArgs gitUiCommands)
        {
            if (!gitUiCommands.IsValidGitWorkingDir(gitUiCommands.GitWorkingDir))
            {
                MessageBox.Show("The current directory is not a valid git repository." + Environment.NewLine +
                                Environment.NewLine + "Gource can be only be started from a valid git repository.");
                return;
            }

            var pathToGource = Settings.GetSetting("Path to \"gource\"");

            if (!string.IsNullOrEmpty(pathToGource))
            {
                if (!File.Exists(pathToGource))
                {
                    if (
                        MessageBox.Show(
                            "Cannot find \"gource\" in the configured path: " + pathToGource +
                            ".\n\n.Do you want to reset the configured path?", "Gource", MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        Settings.SetSetting("Path to \"gource\"", "");
                        pathToGource = Settings.GetSetting("Path to \"gource\"");
                    }
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (
                    MessageBox.Show(
                        "There is no path to \"gource\" configured.\n\nDo you want to automaticly download \"gource\"?",
                        "Download", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(
                            "Cannot find \"gource\".\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                        return;
                    }
                    var downloadDir = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                    var fileName = downloadDir + "\\gource.zip";
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(downloadSize + " bytes downloaded.");
                        Directory.CreateDirectory(downloadDir + "\\gource");
                        UnZipFiles(fileName, downloadDir + "\\gource", true);

                        var newGourcePath = downloadDir + "\\gource\\gource.exe";
                        if (File.Exists(newGourcePath))
                        {
                            Settings.SetSetting("Path to \"gource\"", newGourcePath);
                            MessageBox.Show("\"gource\" has been downloaded and unzipped.");
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(
                            "Downloading failed.\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                    }
                }
            }

            var gourceStart = new GourceStart(pathToGource, gitUiCommands.GitWorkingDir,
                                              Settings.GetSetting("Arguments"));
            gourceStart.ShowDialog();

            Settings.SetSetting("Arguments", gourceStart.GourceArguments);
            Settings.SetSetting("Path to \"gource\"", gourceStart.PathToGource);
        }
예제 #4
0
        public override bool Execute(GitUIBaseEventArgs eventArgs)
        {
            IGitModule gitUiCommands = eventArgs.GitModule;
            var ownerForm = eventArgs.OwnerForm as IWin32Window;
            if (!gitUiCommands.IsValidGitWorkingDir())
            {
                MessageBox.Show(ownerForm, _currentDirectoryIsNotValidGit.Text);
                return false;
            }

            var pathToGource = GourcePath[Settings];

            if (!string.IsNullOrEmpty(pathToGource))
            {
                if (!File.Exists(pathToGource))
                {
                    if (MessageBox.Show(ownerForm,
                            string.Format(_resetConfigPath.Text, pathToGource), _gource.Text, MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        Settings.SetValue<string>(GourcePath.Name, GourcePath.DefaultValue, s => s);
                        pathToGource = GourcePath.DefaultValue;
                    }
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (MessageBox.Show(ownerForm, _doYouWantDownloadGource.Text, _download.Text,
                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(ownerForm, _cannotFindGource.Text);
                        return false;
                    }
                    var downloadDir = Path.GetTempPath();
                    var fileName = Path.Combine(downloadDir, "gource.zip");
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(string.Format(_bytesDownloaded.Text, downloadSize));
                        Directory.CreateDirectory(Path.Combine(downloadDir, "gource"));
                        UnZipFiles(fileName, Path.Combine(downloadDir, "gource"), true);

                        var newGourcePath = Path.Combine(downloadDir, "gource\\gource.exe");
                        if (File.Exists(newGourcePath))
                        {
                            MessageBox.Show(ownerForm, _gourceDownloadedAndUnzipped.Text);
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(ownerForm, _downloadingFailed.Text);
                    }
                }
            }

            using (var gourceStart = new GourceStart(pathToGource, eventArgs, GourceArguments[Settings]))
            {
                gourceStart.ShowDialog(ownerForm);
                Settings.SetValue<string>(GourceArguments.Name, gourceStart.GourceArguments, s => s);
                Settings.SetValue<string>(GourcePath.Name, gourceStart.PathToGource, s => s);
            }
            return true;
        }
예제 #5
0
        public override bool Execute(GitUIBaseEventArgs eventArgs)
        {
            IGitModule gitUiCommands = eventArgs.GitModule;
            var ownerForm = eventArgs.OwnerForm as IWin32Window;
            if (!gitUiCommands.IsValidGitWorkingDir())
            {
                MessageBox.Show(ownerForm, "The current directory is not a valid git repository." + Environment.NewLine +
                                Environment.NewLine + "Gource can be only be started from a valid git repository.");
                return false;
            }

            var pathToGource = GourcePath[Settings];

            if (!string.IsNullOrEmpty(pathToGource))
            {
                if (!File.Exists(pathToGource))
                {
                    if (MessageBox.Show(ownerForm,
                            "Cannot find \"gource\" in the configured path: " + pathToGource +
                            ".\n\n.Do you want to reset the configured path?", "Gource", MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        Settings.SetValue<string>(GourcePath.Name, GourcePath.DefaultValue, s => s);
                        pathToGource = GourcePath.DefaultValue;
                    }
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (MessageBox.Show(ownerForm,
                        "There is no path to \"gource\" configured.\n\nDo you want to automaticly download \"gource\"?",
                        "Download", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(ownerForm,
                            "Cannot find \"gource\".\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                        return false;
                    }
                    var downloadDir = Path.GetTempPath();
                    var fileName = Path.Combine(downloadDir, "gource.zip");
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(downloadSize + " bytes downloaded.");
                        Directory.CreateDirectory(Path.Combine(downloadDir, "gource"));
                        UnZipFiles(fileName, Path.Combine(downloadDir, "gource"), true);

                        var newGourcePath = Path.Combine(downloadDir, "gource\\gource.exe");
                        if (File.Exists(newGourcePath))
                        {
                            MessageBox.Show(ownerForm, "\"gource\" has been downloaded and unzipped.");
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(ownerForm,
                            "Downloading failed.\nPlease download \"gource\" and set the path in the plugins settings dialog.");
                    }
                }
            }

            using (var gourceStart = new GourceStart(pathToGource, eventArgs, GourceArguments[Settings]))
            {
                gourceStart.ShowDialog(ownerForm);
                Settings.SetValue<string>(GourceArguments.Name, gourceStart.GourceArguments, s => s);
                Settings.SetValue<string>(GourcePath.Name, gourceStart.PathToGource, s => s);
            }
            return true;
        }
예제 #6
0
        public override bool Execute(GitUIEventArgs args)
        {
            if (!args.VsrModule.IsValidVersionrWorkingDir())
            {
                MessageBox.Show(args.OwnerForm, _currentDirectoryIsNotValidGit.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            var pathToGource = _gourcePath.ValueOrDefault(Settings);

            if (!File.Exists(pathToGource))
            {
                var result = MessageBox.Show(
                    args.OwnerForm,
                    string.Format(_resetConfigPath.Text, pathToGource), _gource.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    Settings.SetValue(_gourcePath.Name, _gourcePath.DefaultValue, s => s);
                    pathToGource = _gourcePath.DefaultValue;
                }
            }

            if (string.IsNullOrEmpty(pathToGource))
            {
                if (MessageBox.Show(
                        args.OwnerForm, _doYouWantDownloadGource.Text, _download.Text,
                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    var gourceUrl = SearchForGourceUrl();

                    if (string.IsNullOrEmpty(gourceUrl))
                    {
                        MessageBox.Show(args.OwnerForm, _cannotFindGource.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    var downloadDir  = Path.GetTempPath();
                    var fileName     = Path.Combine(downloadDir, "gource.zip");
                    var downloadSize = DownloadFile(gourceUrl, fileName);
                    if (downloadSize > 0)
                    {
                        MessageBox.Show(string.Format(_bytesDownloaded.Text, downloadSize), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Directory.CreateDirectory(Path.Combine(downloadDir, "gource"));
                        UnZipFiles(fileName, Path.Combine(downloadDir, "gource"), true);

                        var newGourcePath = Path.Combine(downloadDir, "gource\\gource.exe");
                        if (File.Exists(newGourcePath))
                        {
                            MessageBox.Show(args.OwnerForm, _gourceDownloadedAndUnzipped.Text, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            pathToGource = newGourcePath;
                        }
                    }
                    else
                    {
                        MessageBox.Show(args.OwnerForm, _downloadingFailed.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            using (var gourceStart = new GourceStart(pathToGource, args, _gourceArguments.ValueOrDefault(Settings)))
            {
                gourceStart.ShowDialog(args.OwnerForm);
                Settings.SetValue(_gourceArguments.Name, gourceStart.GourceArguments, s => s);
                Settings.SetValue(_gourcePath.Name, gourceStart.PathToGource, s => s);
            }

            return(true);
        }