Exemple #1
0
        private static bool LocateMissingGit()
        {
            int dialogResult = -1;

            using Microsoft.WindowsAPICodePack.Dialogs.TaskDialog dialog1 = new()
            {
                InstructionText = ResourceManager.TranslatedStrings.GitExecutableNotFound,
                Icon = TaskDialogStandardIcon.Error,
                StandardButtons = TaskDialogStandardButtons.Cancel,
                Cancelable = true,
            };
            TaskDialogCommandLink btnFindGitExecutable = new("FindGitExecutable", null, ResourceManager.TranslatedStrings.FindGitExecutable);
            btnFindGitExecutable.Click += (s, e) =>
            {
                dialogResult = 0;
                dialog1.Close();
            };
            TaskDialogCommandLink btnInstallGitInstructions = new("InstallGitInstructions", null, ResourceManager.TranslatedStrings.InstallGitInstructions);
            btnInstallGitInstructions.Click += (s, e) =>
            {
                dialogResult = 1;
                dialog1.Close();
            };
            dialog1.Controls.Add(btnFindGitExecutable);
            dialog1.Controls.Add(btnInstallGitInstructions);

            dialog1.Show();
            switch (dialogResult)
            {
                case 0:
                    {
                        using OpenFileDialog dialog = new()
                        {
                            Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                        };
                        if (dialog.ShowDialog(null) == DialogResult.OK)
                        {
                            AppSettings.GitCommandValue = dialog.FileName;
                        }

                        if (CheckSettingsLogic.SolveGitCommand())
                        {
                            return true;
                        }

                        return false;
                    }

                case 1:
                    {
                        OsShellUtil.OpenUrlInDefaultBrowser(@"https://github.com/gitextensions/gitextensions/wiki/Application-Dependencies#git");
                        return false;
                    }

                default:
                    {
                        return false;
                    }
            }
        }
Exemple #2
0
        private bool CheckDiffToolConfiguration()
        {
            DiffTool.Visible = true;
            if (string.IsNullOrEmpty(CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings)))
            {
                RenderSettingUnset(DiffTool, DiffTool_Fix, _adviceDiffToolConfiguration.Text);
                return(false);
            }

            if (EnvUtils.RunningOnWindows())
            {
                if (CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings).Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
                {
                    string p = GetGlobalSetting("difftool.kdiff3.path");
                    if (string.IsNullOrEmpty(p) || !File.Exists(p))
                    {
                        RenderSettingUnset(DiffTool, DiffTool_Fix, _kdiffAsDiffConfiguredButNotFound.Text);
                        return(false);
                    }

                    RenderSettingSet(DiffTool, DiffTool_Fix, _kdiffAsDiffConfigured.Text);
                    return(true);
                }
            }

            string difftool = CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings);

            RenderSettingSet(DiffTool, DiffTool_Fix, string.Format(_diffToolXConfigured.Text, difftool));
            return(true);
        }
        private bool CheckDiffToolConfiguration()
        {
            DiffTool.Visible = true;
            if (string.IsNullOrEmpty(CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings)))
            {
                DiffTool.BackColor   = Color.LightSalmon;
                DiffTool_Fix.Visible = true;
                DiffTool.Text        = _adviceDiffToolConfiguration.Text;
                return(false);
            }
            if (EnvUtils.RunningOnWindows())
            {
                if (CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings).Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
                {
                    string p = GetGlobalSetting("difftool.kdiff3.path");
                    if (string.IsNullOrEmpty(p) || !File.Exists(p))
                    {
                        DiffTool.BackColor   = Color.LightSalmon;
                        DiffTool.Text        = _kdiffAsDiffConfiguredButNotFound.Text;
                        DiffTool_Fix.Visible = true;
                        return(false);
                    }
                    DiffTool.BackColor   = Color.LightGreen;
                    DiffTool.Text        = _kdiffAsDiffConfigured.Text;
                    DiffTool_Fix.Visible = false;
                    return(true);
                }
            }
            string difftool = CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings);

            DiffTool.BackColor   = Color.LightGreen;
            DiffTool.Text        = String.Format(_diffToolXConfigured.Text, difftool);
            DiffTool_Fix.Visible = false;
            return(true);
        }
Exemple #4
0
        private void DiffToolFix_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings)))
            {
                if (MessageBox.Show(this, _noDiffToolConfigured.Text, _noDiffToolConfiguredCaption.Text,
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    CheckSettingsLogic.SolveDiffToolForKDiff();
                    PageHost.LoadAll(); // apply settings to dialog controls (otherwise the later called SaveAndRescan_Click would overwrite settings again)
                }
                else
                {
                    GotoPageGlobalSettings();
                    return;
                }
            }

            if (CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings).Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase))
            {
                CheckSettingsLogic.SolveDiffToolPathForKDiff();
            }

            if (CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings).Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase) &&
                string.IsNullOrEmpty(GetGlobalSetting("difftool.kdiff3.path")))
            {
                MessageBox.Show(this, _kdiff3NotFoundAuto.Text);
                GotoPageGlobalSettings();
                return;
            }

            SaveAndRescan_Click(null, null);
        }
Exemple #5
0
 private bool CheckGitExe()
 {
     return(RenderSettingSetUnset(() => !File.Exists(AppSettings.GitBinDir + "sh.exe") && !File.Exists(AppSettings.GitBinDir + "sh") &&
                                  !CheckSettingsLogic.CheckIfFileIsInPath("sh.exe") && !CheckSettingsLogic.CheckIfFileIsInPath("sh"),
                                  GitBinFound, GitBinFound_Fix,
                                  _linuxToolsSshNotFound.Text, _linuxToolsSshFound.Text));
 }
        public override void OnPageShown()
        {
            {
                bool canFindGitCmd = CheckSettingsLogic.CanFindGitCmd();

                GlobalUserName.Enabled                = canFindGitCmd;
                GlobalUserEmail.Enabled               = canFindGitCmd;
                GlobalEditor.Enabled                  = canFindGitCmd;
                CommitTemplatePath.Enabled            = canFindGitCmd;
                _NO_TRANSLATE_GlobalMergeTool.Enabled = canFindGitCmd;
                MergetoolPath.Enabled                 = canFindGitCmd;
                MergeToolCmd.Enabled                  = canFindGitCmd;
                GlobalKeepMergeBackup.Enabled         = canFindGitCmd;
                InvalidGitPathGlobal.Visible          = !canFindGitCmd;
            }

            if (_NO_TRANSLATE_GlobalMergeTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase) &&
                string.IsNullOrEmpty(MergeToolCmd.Text))
            {
                MergeToolCmd.Enabled = false;
            }
            else
            {
                MergeToolCmd.Enabled = true;
            }
        }
        protected override void SettingsToPage()
        {
            CommonLogic.EncodingToCombo(CurrentSettings.FilesEncoding, Global_FilesEncoding);

            GlobalUserName.Text  = CurrentSettings.GetValue(SettingKeyString.UserName);
            GlobalUserEmail.Text = CurrentSettings.GetValue(SettingKeyString.UserEmail);
            GlobalEditor.Text    = CurrentSettings.GetValue("core.editor");
            _NO_TRANSLATE_GlobalMergeTool.Text = CurrentSettings.GetValue("merge.tool");
            CommitTemplatePath.Text            = CurrentSettings.GetValue("commit.template");

            MergetoolPath.Text = CurrentSettings.GetValue(string.Format("mergetool.{0}.path", _NO_TRANSLATE_GlobalMergeTool.Text));
            MergeToolCmd.Text  = CurrentSettings.GetValue(string.Format("mergetool.{0}.cmd", _NO_TRANSLATE_GlobalMergeTool.Text));

            _NO_TRANSLATE_GlobalDiffTool.Text = CheckSettingsLogic.GetDiffToolFromConfig(CurrentSettings);

            DifftoolPath.Text = CurrentSettings.GetValue(string.Format("difftool.{0}.path", _NO_TRANSLATE_GlobalDiffTool.Text));
            DifftoolCmd.Text  = CurrentSettings.GetValue(string.Format("difftool.{0}.cmd", _NO_TRANSLATE_GlobalDiffTool.Text));

            GlobalKeepMergeBackup.SetNullableChecked(CurrentSettings.mergetool.keepBackup.Value);

            globalAutoCrlfFalse.Checked  = CurrentSettings.core.autocrlf.Value == AutoCRLFType.@false;
            globalAutoCrlfInput.Checked  = CurrentSettings.core.autocrlf.Value == AutoCRLFType.input;
            globalAutoCrlfTrue.Checked   = CurrentSettings.core.autocrlf.Value == AutoCRLFType.@true;
            globalAutoCrlfNotSet.Checked = !CurrentSettings.core.autocrlf.Value.HasValue;
        }
        /// <summary>
        /// silently does not save some settings if Git is not configured correctly
        /// (user notification is done elsewhere)
        /// </summary>
        protected override void PageToSettings()
        {
            CurrentSettings.FilesEncoding = CommonLogic.ComboToEncoding(Global_FilesEncoding);

            if (!CheckSettingsLogic.CanFindGitCmd())
            {
                return;
            }

            CurrentSettings.SetValue(SettingKeyString.UserName, GlobalUserName.Text);
            CurrentSettings.SetValue(SettingKeyString.UserEmail, GlobalUserEmail.Text);
            CurrentSettings.SetValue("commit.template", txtCommitTemplatePath.Text);
            CurrentSettings.SetPathValue("core.editor", GlobalEditor.Text);

            // TODO: why use GUI???
            var diffTool = _NO_TRANSLATE_cboDiffTool.Text;

            if (!string.IsNullOrWhiteSpace(diffTool))
            {
                _diffMergeToolConfigurationManager.ConfigureDiffMergeTool(diffTool, DiffMergeToolType.Diff, txtDiffToolPath.Text, txtDiffToolCommand.Text);
            }
            else
            {
                _diffMergeToolConfigurationManager.UnsetCurrentTool(DiffMergeToolType.Diff);
            }

            // TODO: merge.guitool???
            var mergeTool = _NO_TRANSLATE_cboMergeTool.Text;

            if (!string.IsNullOrWhiteSpace(mergeTool))
            {
                _diffMergeToolConfigurationManager.ConfigureDiffMergeTool(mergeTool, DiffMergeToolType.Merge, txtMergeToolPath.Text, txtMergeToolCommand.Text);
            }
            else
            {
                _diffMergeToolConfigurationManager.UnsetCurrentTool(DiffMergeToolType.Merge);
            }

            if (globalAutoCrlfFalse.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.@false;
            }

            if (globalAutoCrlfInput.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.input;
            }

            if (globalAutoCrlfTrue.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.@true;
            }

            if (globalAutoCrlfNotSet.Checked)
            {
                CurrentSettings.core.autocrlf.Value = null;
            }
        }
Exemple #9
0
        public LocalSettingsSettingsPage(CommonLogic commonLogic, CheckSettingsLogic checkSettingsLogic, GitModule gitModule)
            : this()
        {
            _commonLogic        = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule          = gitModule;

            _commonLogic.FillEncodings(Local_FilesEncoding);
        }
        public LocalSettingsSettingsPage(CommonLogic commonLogic, CheckSettingsLogic checkSettingsLogic, GitModule gitModule)
            : this()
        {
            _commonLogic = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule = gitModule;

            _commonLogic.FillEncodings(Local_FilesEncoding);
        }
        public GitSettingsPage(CheckSettingsLogic checkSettingsLogic,
                               ISettingsPageHost settingsPageHost)
        {
            InitializeComponent();
            Text = "Git";
            Translate();

            _checkSettingsLogic = checkSettingsLogic;
            _settingsPageHost   = settingsPageHost;
        }
        public GitSettingsPage(CheckSettingsLogic checkSettingsLogic,
            ISettingsPageHost settingsPageHost)
        {
            InitializeComponent();
            Text = "Git";
            Translate();

            _checkSettingsLogic = checkSettingsLogic;
            _settingsPageHost = settingsPageHost;
        }
        private void DiffToolFix_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CheckSettingsLogic.GetDiffToolFromConfig(CheckSettingsLogic.CommonLogic.ConfigFileSettingsSet.GlobalSettings)))
            {
                GotoPageGlobalSettings();
                return;
            }

            SaveAndRescan_Click(null, null);
        }
        private void BrowseGitBinPath_Click(object sender, EventArgs e)
        {
            CheckSettingsLogic.SolveLinuxToolsDir(GitBinPath.Text.Trim());

            var userSelectedPath = OsShellUtil.PickFolder(this, AppSettings.GitBinDir);

            if (userSelectedPath != null)
            {
                GitBinPath.Text = userSelectedPath;
            }
        }
Exemple #15
0
 public ChecklistSettingsPage(CommonLogic commonLogic,
                              CheckSettingsLogic checkSettingsLogic,
                              GitModule gitModule,
                              ISettingsPageHost settingsPageHost)
     : this()
 {
     _commonLogic        = commonLogic;
     _checkSettingsLogic = checkSettingsLogic;
     _gitModule          = gitModule;
     _settingsPageHost   = settingsPageHost;
 }
        private bool CheckGitCmdValid()
        {
            GitFound.Visible = true;
            if (!CheckSettingsLogic.CanFindGitCmd())
            {
                RenderSettingUnset(GitFound, GitFound_Fix, _gitNotFound.Text);
                return(false);
            }

            RenderSettingSet(GitFound, GitFound_Fix, string.Format(_gitVersionFound.Text, VsrVersion.Current));
            return(true);
        }
        public LocalSettingsSettingsPage(CommonLogic commonLogic, CheckSettingsLogic checkSettingsLogic, GitModule gitModule)
        {
            InitializeComponent();
            Translate();

            _commonLogic = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule = gitModule;

            Text = "Local Settings";

            _commonLogic.FillEncodings(Local_FilesEncoding);
        }
        private void gitCredentialWinStore_Fix_Click(object sender, EventArgs e)
        {
            if (CheckSettingsLogic.SolveGitCredentialStore())
            {
                MessageBox.Show(this, _gitCredentialWinStoreHelperInstalled.Text);
            }
            else
            {
                MessageBox.Show(this, _noCredentialsHelperInstalledTryGCS.Text);
            }

            CheckSettings();
        }
        public override void OnPageShown()
        {
            bool canFindGitCmd = CheckSettingsLogic.CanFindGitCmd();

            GlobalUserName.Enabled             = canFindGitCmd;
            GlobalUserEmail.Enabled            = canFindGitCmd;
            GlobalEditor.Enabled               = canFindGitCmd;
            txtCommitTemplatePath.Enabled      = canFindGitCmd;
            _NO_TRANSLATE_cboMergeTool.Enabled = canFindGitCmd;
            txtMergeToolPath.Enabled           = canFindGitCmd;
            txtMergeToolCommand.Enabled        = canFindGitCmd;
            InvalidGitPathGlobal.Visible       = !canFindGitCmd;
        }
        private void BrowseGitBinPath_Click(object sender, EventArgs e)
        {
            CheckSettingsLogic.SolveLinuxToolsDir(GitBinPath.Text.Trim());

            using (var browseDialog = new FolderBrowserDialog {
                SelectedPath = AppSettings.GitBinDir
            })
            {
                if (browseDialog.ShowDialog(this) == DialogResult.OK)
                {
                    GitBinPath.Text = browseDialog.SelectedPath;
                }
            }
        }
Exemple #21
0
        private void GitBinFound_Click(object sender, EventArgs e)
        {
            if (!CheckSettingsLogic.SolveLinuxToolsDir())
            {
                MessageBox.Show(this, _linuxToolsShNotFound.Text, _linuxToolsShNotFoundCaption.Text);
                PageHost.GotoPage(GitSettingsPage.GetPageReference());
                return;
            }

            MessageBox.Show(this, string.Format(_shCanBeRun.Text, AppSettings.GitBinDir), _shCanBeRunCaption.Text);
            ////GitBinPath.Text = Settings.GitBinDir;
            PageHost.LoadAll(); // apply settings to dialog controls (otherwise the later called SaveAndRescan_Click would overwrite settings again)
            SaveAndRescan_Click(null, null);
        }
Exemple #22
0
        private void GitFound_Click(object sender, EventArgs e)
        {
            if (!CheckSettingsLogic.SolveGitCommand())
            {
                MessageBox.Show(this, _solveGitCommandFailed.Text, _solveGitCommandFailedCaption.Text);

                PageHost.GotoPage(GitSettingsPage.GetPageReference());
                return;
            }

            MessageBox.Show(this, string.Format(_gitCanBeRun.Text, AppSettings.GitCommandValue), _gitCanBeRunCaption.Text);

            PageHost.GotoPage(GitSettingsPage.GetPageReference());
            SaveAndRescan_Click(null, null);
        }
        /// <summary>
        /// silently does not save some settings if Git is not configured correctly
        /// (user notification is done elsewhere)
        /// </summary>
        protected override void PageToSettings()
        {
            CurrentSettings.FilesEncoding = CommonLogic.ComboToEncoding(Global_FilesEncoding);

            if (!CheckSettingsLogic.CanFindGitCmd())
            {
                return;
            }

            CurrentSettings.SetValue(SettingKeyString.UserName, GlobalUserName.Text);
            CurrentSettings.SetValue(SettingKeyString.UserEmail, GlobalUserEmail.Text);
            CurrentSettings.SetValue("commit.template", CommitTemplatePath.Text);
            CurrentSettings.SetPathValue("core.editor", GlobalEditor.Text);

            var diffTool = _NO_TRANSLATE_GlobalDiffTool.Text;

            CheckSettingsLogic.SetDiffToolToConfig(CurrentSettings, diffTool);
            CurrentSettings.SetPathValue($"difftool.{diffTool}.path", DifftoolPath.Text);
            CurrentSettings.SetPathValue($"difftool.{diffTool}.cmd", DifftoolCmd.Text);

            var mergeTool = _NO_TRANSLATE_GlobalMergeTool.Text;

            CurrentSettings.SetValue("merge.tool", mergeTool);
            CurrentSettings.SetPathValue($"mergetool.{mergeTool}.path", MergetoolPath.Text);
            CurrentSettings.SetPathValue($"mergetool.{mergeTool}.cmd", MergeToolCmd.Text);

            CurrentSettings.mergetool.keepBackup.Value = GlobalKeepMergeBackup.GetNullableChecked();

            if (globalAutoCrlfFalse.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.@false;
            }

            if (globalAutoCrlfInput.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.input;
            }

            if (globalAutoCrlfTrue.Checked)
            {
                CurrentSettings.core.autocrlf.Value = AutoCRLFType.@true;
            }

            if (globalAutoCrlfNotSet.Checked)
            {
                CurrentSettings.core.autocrlf.Value = null;
            }
        }
Exemple #24
0
        private static bool LocateMissingGit()
        {
            int dialogResult = PSTaskDialog.cTaskDialog.ShowCommandBox(Title: "Error",
                                                                       MainInstruction: Strings.GitExecutableNotFound,
                                                                       Content: null,
                                                                       ExpandedInfo: null,
                                                                       Footer: null,
                                                                       VerificationText: null,
                                                                       CommandButtons: $"{Strings.FindGitExecutable}|{Strings.InstallGitInstructions}",
                                                                       ShowCancelButton: true,
                                                                       MainIcon: PSTaskDialog.eSysIcons.Error,
                                                                       FooterIcon: PSTaskDialog.eSysIcons.Warning);

            switch (dialogResult)
            {
            case 0:
            {
                using (var dialog = new OpenFileDialog
                    {
                        Filter = @"git.exe|git.exe|git.cmd|git.cmd",
                    })
                {
                    if (dialog.ShowDialog(null) == DialogResult.OK)
                    {
                        AppSettings.GitCommandValue = dialog.FileName;
                    }

                    if (CheckSettingsLogic.SolveGitCommand())
                    {
                        return(true);
                    }
                }

                return(false);
            }

            case 1:
            {
                Process.Start(@"https://github.com/gitextensions/gitextensions/wiki/Git");
                return(false);
            }

            default:
            {
                return(false);
            }
            }
        }
 private bool CheckGitExe()
 {
     GitBinFound.Visible = true;
     if (!File.Exists(AppSettings.GitBinDir + "sh.exe") && !File.Exists(AppSettings.GitBinDir + "sh") &&
         !CheckSettingsLogic.CheckIfFileIsInPath("sh.exe") && !CheckSettingsLogic.CheckIfFileIsInPath("sh"))
     {
         GitBinFound.BackColor   = Color.LightSalmon;
         GitBinFound.Text        = _linuxToolsSshNotFound.Text;
         GitBinFound_Fix.Visible = true;
         return(false);
     }
     GitBinFound_Fix.Visible = false;
     GitBinFound.BackColor   = Color.LightGreen;
     GitBinFound.Text        = _linuxToolsSshFound.Text;
     return(true);
 }
        private void BrowseGitPath_Click(object sender, EventArgs e)
        {
            CheckSettingsLogic.SolveGitCommand(GitPath.Text.Trim());

            using (var browseDialog = new OpenFileDialog
            {
                FileName = AppSettings.GitCommandValue,
                Filter = "Git.cmd (git.cmd)|git.cmd|Git.exe (git.exe)|git.exe|Git (git)|git"
            })
            {
                if (browseDialog.ShowDialog(this) == DialogResult.OK)
                {
                    GitPath.Text = browseDialog.FileName;
                }
            }
        }
        public override void OnPageShown()
        {
            bool canFindGitCmd = CheckSettingsLogic.CanFindGitCmd();

            GlobalUserName.Enabled                = canFindGitCmd;
            GlobalUserEmail.Enabled               = canFindGitCmd;
            GlobalEditor.Enabled                  = canFindGitCmd;
            CommitTemplatePath.Enabled            = canFindGitCmd;
            _NO_TRANSLATE_GlobalMergeTool.Enabled = canFindGitCmd;
            MergetoolPath.Enabled                 = canFindGitCmd;
            MergeToolCmd.Enabled                  = canFindGitCmd;
            GlobalKeepMergeBackup.Enabled         = canFindGitCmd;
            InvalidGitPathGlobal.Visible          = !canFindGitCmd;

            MergeToolCmd.Enabled = !string.IsNullOrEmpty(MergeToolCmd.Text);
        }
        public GlobalSettingsSettingsPage(CommonLogic commonLogic, CheckSettingsLogic checkSettingsLogic, GitModule gitModule)
            : this()
        {
            _commonLogic = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule = gitModule;

            _commonLogic.FillEncodings(Global_FilesEncoding);

            string npp = MergeToolsHelper.FindFileInFolders("notepad++.exe", "Notepad++");
            if (string.IsNullOrEmpty(npp))
                npp = "notepad++";
            else
                npp = "\"" + npp + "\"";

            GlobalEditor.Items.AddRange(new Object[] { "\"" + Settings.GetGitExtensionsFullPath() + "\" fileeditor", "vi", "notepad", npp + " -multiInst -nosession" });
        }
Exemple #29
0
        private bool CheckGitCmdValid()
        {
            GitFound.Visible = true;
            if (!CheckSettingsLogic.CanFindGitCmd())
            {
                RenderSettingUnset(GitFound, GitFound_Fix, _gitNotFound.Text);
                return(false);
            }

            if (GitCommandHelpers.VersionInUse < GitVersion.LastSupportedVersion)
            {
                RenderSettingUnset(GitFound, GitFound_Fix, string.Format(_wrongGitVersion.Text, GitCommandHelpers.VersionInUse, GitVersion.LastSupportedVersion));
                return(false);
            }

            RenderSettingSet(GitFound, GitFound_Fix, string.Format(_gitVersionFound.Text, GitCommandHelpers.VersionInUse));
            return(true);
        }
        public FormSettings([NotNull] GitUICommands commands, SettingsPageReference initialPage = null)
            : base(commands)
        {
            InitializeComponent();

            _translatedTitle = Text;

#if DEBUG
            buttonDiscard.Visible = true;
#endif

            _commonLogic = new CommonLogic(Module);

            CheckSettingsLogic = new CheckSettingsLogic(_commonLogic);

            InitializeComplete();
            _initialPage = initialPage;
        }
        /// <summary>
        /// silently does not save some settings if Git is not configured correctly
        /// (user notification is done elsewhere)
        /// </summary>
        protected override void PageToSettings()
        {
            CurrentSettings.FilesEncoding = CommonLogic.ComboToEncoding(Global_FilesEncoding);

            if (CheckSettingsLogic.CanFindGitCmd())
            {
                CurrentSettings.SetValue("user.name", GlobalUserName.Text);
                CurrentSettings.SetValue("user.email", GlobalUserEmail.Text);
                CurrentSettings.SetValue("commit.template", CommitTemplatePath.Text);
                CurrentSettings.SetPathValue("core.editor", GlobalEditor.Text);

                CheckSettingsLogic.SetDiffToolToConfig(CurrentSettings, GlobalDiffTool.Text);

                CurrentSettings.SetPathValue(string.Format("difftool.{0}.path", GlobalDiffTool.Text), DifftoolPath.Text);
                CurrentSettings.SetPathValue(string.Format("difftool.{0}.cmd", GlobalDiffTool.Text), DifftoolCmd.Text);

                CurrentSettings.SetValue("merge.tool", GlobalMergeTool.Text);

                CurrentSettings.SetPathValue(string.Format("mergetool.{0}.path", GlobalMergeTool.Text), MergetoolPath.Text);
                CurrentSettings.SetPathValue(string.Format("mergetool.{0}.cmd", GlobalMergeTool.Text), MergeToolCmd.Text);

                CurrentSettings.mergetool.keepBackup.Value = GlobalKeepMergeBackup.GetNullableChecked();

                if (globalAutoCrlfFalse.Checked)
                {
                    CurrentSettings.core.autocrlf.Value = AutoCRLFType.False;
                }
                if (globalAutoCrlfInput.Checked)
                {
                    CurrentSettings.core.autocrlf.Value = AutoCRLFType.Input;
                }
                if (globalAutoCrlfTrue.Checked)
                {
                    CurrentSettings.core.autocrlf.Value = AutoCRLFType.True;
                }
                if (globalAutoCrlfNotSet.Checked)
                {
                    CurrentSettings.core.autocrlf.Value = null;
                }
            }
        }
        public bool CheckGitCredentialStore()
        {
            gitCredentialWinStore.Visible = true;

            bool isValid = CheckSettingsLogic.CheckGitCredentialStore();

            if (isValid)
            {
                gitCredentialWinStore.BackColor   = Color.LightGreen;
                gitCredentialWinStore.Text        = _credentialHelperInstalled.Text;
                gitCredentialWinStore_Fix.Visible = false;
            }
            else
            {
                gitCredentialWinStore.BackColor   = Color.LightSalmon;
                gitCredentialWinStore.Text        = _noCredentialsHelperInstalled.Text;
                gitCredentialWinStore_Fix.Visible = true;
            }

            return(isValid);
        }
Exemple #33
0
        private void MergeToolFix_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(CommonLogic.GetGlobalMergeTool()))
            {
                if (
                    MessageBox.Show(this, _noMergeToolConfigured.Text,
                                    _noMergeToolConfiguredCaption.Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    CommonLogic.SetGlobalMergeTool("kdiff3");
                    PageHost.LoadAll(); // apply settings to dialog controls (otherwise the later called SaveAndRescan_Click would overwrite settings again)
                }
                else
                {
                    GotoPageGlobalSettings();
                    return;
                }
            }

            if (CommonLogic.IsMergeTool("kdiff3"))
            {
                CheckSettingsLogic.SolveMergeToolPathForKDiff();
            }
            else if (_autoConfigMergeTools.Any(tool => CommonLogic.IsMergeTool(tool)))
            {
                CheckSettingsLogic.AutoConfigMergeToolCmd();

                SetGlobalPathSetting(
                    string.Format("mergetool.{0}.cmd", CommonLogic.GetGlobalMergeTool()), CheckSettingsLogic.GetMergeToolCmdText());
            }

            if (CommonLogic.IsMergeTool("kdiff3") &&
                string.IsNullOrEmpty(GetGlobalSetting("mergetool.kdiff3.path")))
            {
                MessageBox.Show(this, _kdiff3NotFoundAuto.Text);
                GotoPageGlobalSettings();
                return;
            }

            SaveAndRescan_Click(null, null);
        }
Exemple #34
0
        public GlobalSettingsSettingsPage(CommonLogic commonLogic, CheckSettingsLogic checkSettingsLogic, GitModule gitModule)
            : this()
        {
            _commonLogic        = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule          = gitModule;

            _commonLogic.FillEncodings(Global_FilesEncoding);

            string npp = MergeToolsHelper.FindFileInFolders("notepad++.exe", "Notepad++");

            if (string.IsNullOrEmpty(npp))
            {
                npp = "notepad++";
            }
            else
            {
                npp = "\"" + npp + "\"";
            }

            GlobalEditor.Items.AddRange(new Object[] { "\"" + Settings.GetGitExtensionsFullPath() + "\" fileeditor", "vi", "notepad", npp + " -multiInst -nosession" });
        }
 public ChecklistSettingsPage(CommonLogic commonLogic,
     CheckSettingsLogic checkSettingsLogic,
     GitModule gitModule,
     ISettingsPageHost settingsPageHost)
     : this()
 {
     _commonLogic = commonLogic;
     _checkSettingsLogic = checkSettingsLogic;
     _gitModule = gitModule;
     _settingsPageHost = settingsPageHost;
 }
        public ChecklistSettingsPage(CommonLogic commonLogic,
            CheckSettingsLogic checkSettingsLogic,
            GitModule gitModule,
            ISettingsPageHost settingsPageHost)
        {
            InitializeComponent();
            Translate();

            _commonLogic = commonLogic;
            _checkSettingsLogic = checkSettingsLogic;
            _gitModule = gitModule;
            _settingsPageHost = settingsPageHost;

            Text = "Checklist";
        }
 public SettingsPageHostMock(CheckSettingsLogic aCheckSettingsLogic)
 {
     _CheckSettingsLogic = aCheckSettingsLogic;
 }