public FormSettigns() { InitializeComponent(); CheckSettings(); MaxCommits.Value = GitCommands.Settings.MaxCommits; GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); UserName.Text = GitCommands.GitCommands.GetSetting("user.name"); UserEmail.Text = GitCommands.GitCommands.GetSetting("user.email"); Editor.Text = GitCommands.GitCommands.GetSetting("core.editor"); MergeTool.Text = GitCommands.GitCommands.GetSetting("merge.tool"); KeepMergeBackup.Checked = GitCommands.GitCommands.GetSetting("mergetool.keepBackup").Trim() == "true"; GlobalUserName.Text = gitCommands.GetGlobalSetting("user.name"); GlobalUserEmail.Text = gitCommands.GetGlobalSetting("user.email"); GlobalEditor.Text = gitCommands.GetGlobalSetting("core.editor"); GlobalMergeTool.Text = gitCommands.GetGlobalSetting("merge.tool"); GlobalKeepMergeBackup.Checked = gitCommands.GetGlobalSetting("mergetool.keepBackup").Trim() == "true"; }
public static bool SolveKDiff() { GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); string mergeTool = gitCommands.GetGlobalSetting("merge.tool"); if (string.IsNullOrEmpty(mergeTool)) { mergeTool = "kdiff3"; gitCommands.SetGlobalSetting("merge.tool", mergeTool); } if (mergeTool.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase)) return SolveKDiffPath(gitCommands); return true; }
private void LoadSettings() { try { SmtpServer.Text = GitCommands.Settings.Smtp; MaxCommits.Value = GitCommands.Settings.MaxCommits; GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); GitPath.Text = GitCommands.Settings.GitDir; GitBinPath.Text = GitCommands.Settings.GitBinDir; UserName.Text = GitCommands.GitCommands.GetSetting("user.name"); UserEmail.Text = GitCommands.GitCommands.GetSetting("user.email"); Editor.Text = GitCommands.GitCommands.GetSetting("core.editor"); MergeTool.Text = GitCommands.GitCommands.GetSetting("merge.tool"); Dictionary.Text = GitCommands.Settings.Dictionary; GlobalUserName.Text = gitCommands.GetGlobalSetting("user.name"); GlobalUserEmail.Text = gitCommands.GetGlobalSetting("user.email"); GlobalEditor.Text = gitCommands.GetGlobalSetting("core.editor"); GlobalMergeTool.Text = gitCommands.GetGlobalSetting("merge.tool"); SetCheckboxFromString(KeepMergeBackup, GitCommands.GitCommands.GetSetting("mergetool.keepBackup")); SetComboBoxFromString(LocalAutoCRLF, GitCommands.GitCommands.GetSetting("core.autocrlf")); if (!string.IsNullOrEmpty(GlobalMergeTool.Text)) MergetoolPath.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".path"); if (!string.IsNullOrEmpty(GlobalMergeTool.Text)) MergeToolCmd.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text + ".cmd"); SetCheckboxFromString(GlobalKeepMergeBackup, gitCommands.GetGlobalSetting("mergetool.keepBackup")); SetComboBoxFromString(GlobalAutoCRLF, gitCommands.GetGlobalSetting("core.autocrlf")); PlinkPath.Text = GitCommands.Settings.Plink; PuttygenPath.Text = GitCommands.Settings.Puttygen; PageantPath.Text = GitCommands.Settings.Pageant; AutostartPageant.Checked = GitCommands.Settings.AutoStartPageant; CloseProcessDialog.Checked = GitCommands.Settings.CloseProcessDialog; ShowRevisionGraph.Checked = GitCommands.Settings.ShowRevisionGraph; ShowGitCommandLine.Checked = GitCommands.Settings.ShowGitCommandLine; UseFastChecks.Checked = GitCommands.Settings.UseFastChecks; ShowRelativeDate.Checked = GitCommands.Settings.RelativeDate; if (string.IsNullOrEmpty(GitCommands.GitCommands.GetSsh())) OpenSSH.Checked = true; else if (GitCommands.GitCommands.Plink()) Putty.Checked = true; else { OtherSsh.Text = GitCommands.GitCommands.GetSsh(); Other.Checked = true; } EnableSshOptions(); } catch (Exception ex) { MessageBox.Show("Could not load settigns.\n\n" + ex.Message); } }
private void GlobalMergeTool_TextChanged(object sender, EventArgs e) { GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); MergetoolPath.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".path"); MergeToolCmd.Text = gitCommands.GetGlobalSetting("mergetool." + GlobalMergeTool.Text.Trim() + ".cmd"); button1_Click_1(null, null); }
private void DiffTool_Click(object sender, EventArgs e) { GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool"))) { if (MessageBox.Show("There is no mergetool configured. Do you want to configure kdiff3 as your mergetool?" + Environment.NewLine + "Select no if you want to configure a different mergetool yourself.", "Mergetool", MessageBoxButtons.YesNo) == DialogResult.Yes) { SolveKDiff(); GlobalMergeTool.Text = "kdiff3"; } else { tabControl1.SelectTab("GlobalSettingsPage"); return; } } if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase)) { SolveKDiffPath(gitCommands); } else if (gitCommands.GetGlobalSetting("merge.tool").Equals("p4merge", StringComparison.CurrentCultureIgnoreCase) || gitCommands.GetGlobalSetting("merge.tool").Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase)) { AutoConfigMergeToolcmd(); gitCommands.SetGlobalSetting("mergetool." + gitCommands.GetGlobalSetting("merge.tool") + ".cmd", MergeToolCmd.Text); } if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase) && string.IsNullOrEmpty(gitCommands.GetGlobalSetting("mergetool.kdiff3.path"))) { MessageBox.Show("Path to kdiff3 could not be found automatically." + Environment.NewLine + "Please make sure KDiff3 is installed or set path manually."); tabControl1.SelectTab("GlobalSettingsPage"); return; } Rescan_Click(null, null); }
private void button1_Click_1(object sender, EventArgs e) { GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); if (GlobalMergeTool.Text.Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase)) { MergeToolCmd.Text = ""; string kdiff3path = gitCommands.GetGlobalSetting("mergetool.kdiff3.path"); if (!kdiff3path.Contains("kdiff3.exe")) kdiff3path = ""; if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path)) { kdiff3path = @"c:\Program Files\KDiff3\kdiff3.exe"; if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path)) { kdiff3path = @"c:\Program Files (x86)\KDiff3\kdiff3.exe"; if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path)) { kdiff3path = GetRegistryValue(Registry.LocalMachine, "SOFTWARE\\KDiff3", "") + "\\kdiff3.exe"; if (string.IsNullOrEmpty(kdiff3path) || !File.Exists(kdiff3path)) { kdiff3path = MergetoolPath.Text; if (!kdiff3path.Contains("kdiff3.exe")) kdiff3path = ""; } } } } MergetoolPath.Text = kdiff3path; } AutoConfigMergeToolcmd(); }
public bool CheckSettings() { bool bValid = true; try { if (string.IsNullOrEmpty(GitCommands.Settings.GetInstallDir())) { GitExtensionsInstall.BackColor = Color.LightSalmon; GitExtensionsInstall.Text = "Registry entry missing [Software\\GitExtensions\\GitExtensions\\1.0.0.0\\InstallDir]."; bValid = false; } else { GitExtensionsInstall.BackColor = Color.LightGreen; GitExtensionsInstall.Text = "GitExtensions is properly registered."; } if (string.IsNullOrEmpty(GetRegistryValue(Registry.LocalMachine, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", "{3C16B20A-BA16-4156-916F-0A375ECFFE24}")) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "*\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\Background\\shellex\\ContextMenuHandlers\\GitExtensions2", null))) { ShellExtensionsRegistered.BackColor = Color.LightSalmon; ShellExtensionsRegistered.Text = "GitExtensionsShellEx.dll needs to be registered in order to use the shell extensions."; bValid = false; } else { ShellExtensionsRegistered.BackColor = Color.LightGreen; ShellExtensionsRegistered.Text = "Shell extensions registered properly."; } GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.name")) || string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.email"))) { UserNameSet.BackColor = Color.LightSalmon; UserNameSet.Text = "You need to configure a user name and an email address."; bValid = false; } else { UserNameSet.BackColor = Color.LightGreen; UserNameSet.Text = "There is a user name and an email address configured."; } if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool"))) { DiffTool.BackColor = Color.LightSalmon; DiffTool.Text = "You need to configure merge tool in order to solve mergeconflicts (kdiff3 for example)."; bValid = false; } else { if (gitCommands.GetGlobalSetting("merge.tool").Equals("kdiff3", StringComparison.CurrentCultureIgnoreCase)) { string p = gitCommands.GetGlobalSetting("mergetool.kdiff3.path"); if (string.IsNullOrEmpty(p) || !File.Exists(p)) { DiffTool.BackColor = Color.LightSalmon; DiffTool.Text = "KDiff3 is configured as mergetool, but the path to kdiff.exe is not configured."; bValid = false; } else { DiffTool.BackColor = Color.LightGreen; DiffTool.Text = "KDiff3 is configured as mergetool."; } } else { string mergetool = gitCommands.GetGlobalSetting("merge.tool"); if (mergetool.Equals("p4merge", StringComparison.CurrentCultureIgnoreCase) || mergetool.Equals("TortoiseMerge", StringComparison.CurrentCultureIgnoreCase)) { string p = gitCommands.GetGlobalSetting("mergetool." + mergetool + ".cmd"); if (string.IsNullOrEmpty(p)) { DiffTool.BackColor = Color.LightSalmon; DiffTool.Text = mergetool + " is configured as mergetool, this is a custom mergetool and needs a custom cmd to be configured."; bValid = false; } else { DiffTool.BackColor = Color.LightGreen; DiffTool.Text = "There is a custom mergetool configured: " + mergetool; } } else { DiffTool.BackColor = Color.LightGreen; DiffTool.Text = "There is a mergetool configured."; } } } if (!CanFindGitCmd()) { GitFound.BackColor = Color.LightSalmon; GitFound.Text = "git.cmd not found. To solve this problem you can set the correct path in settings."; bValid = false; } else { GitFound.BackColor = Color.LightGreen; GitFound.Text = "git.cmd is found on your computer."; } if (string.IsNullOrEmpty(GitCommands.GitCommands.RunCmd(GitCommands.Settings.GitBinDir + "git.exe", ""))) { GitBinFound.BackColor = Color.LightSalmon; GitBinFound.Text = "git.exe not found. To solve this problem you can set the correct path in settings."; bValid = false; } else { GitBinFound.BackColor = Color.LightGreen; GitBinFound.Text = "git.exe is found on your computer."; } if (GitCommands.GitCommands.Plink()) { if (!File.Exists(GitCommands.Settings.Plink) || !File.Exists(GitCommands.Settings.Puttygen) || !File.Exists(GitCommands.Settings.Pageant)) { SshConfig.BackColor = Color.LightSalmon; SshConfig.Text = "PuTTY is configured as SSH client but cannot find plink.exe, puttygen.exe or pageant.exe."; bValid = false; } else { SshConfig.BackColor = Color.LightGreen; SshConfig.Text = "SSH client PuTTY is configured properly"; } } else { SshConfig.BackColor = Color.LightGreen; if (string.IsNullOrEmpty(GitCommands.GitCommands.GetSsh())) SshConfig.Text = "Default SSH client, OpenSSH, will be used. (commandline window will appear on pull, push and clone operations)"; else SshConfig.Text = "Unknown SSH client configured: " + GitCommands.GitCommands.GetSsh(); } } catch { } if ((Application.UserAppDataRegistry.GetValue("checksettings") == null || Application.UserAppDataRegistry.GetValue("checksettings").ToString() == "true")) { CheckAtStartup.Checked = true; } else { CheckAtStartup.Checked = false; } if (bValid && CheckAtStartup.Checked) { Application.UserAppDataRegistry.SetValue("checksettings", false); CheckAtStartup.Checked = false; } return bValid; }
public bool CheckSettings() { bool bValid = true; try { if (string.IsNullOrEmpty(GetRegistryValue(Registry.LocalMachine, "Software\\GitExtensions", "InstallDir")) || !File.Exists(GetRegistryValue(Registry.LocalMachine, "Software\\GitExtensions", "InstallDir") + "\\GitExtensions.exe")) { GitExtensionsInstall.BackColor = Color.LightSalmon; GitExtensionsInstall.Text = "Registry entry missing [HKEY_LOCAL_MACHINE\\SOFTWARE\\GitExtensions\\InstallDir]."; bValid = false; } else { GitExtensionsInstall.BackColor = Color.LightGreen; GitExtensionsInstall.Text = "GitExtensions is properly registered."; } if (string.IsNullOrEmpty(GetRegistryValue(Registry.LocalMachine, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", "{3C16B20A-BA16-4156-916F-0A375ECFFE24}")) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "*\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\shellex\\ContextMenuHandlers\\GitExtensions2", null)) || string.IsNullOrEmpty(GetRegistryValue(Registry.ClassesRoot, "Directory\\Background\\shellex\\ContextMenuHandlers\\GitExtensions2", null))) { ShellExtensionsRegistered.BackColor = Color.LightSalmon; ShellExtensionsRegistered.Text = "GitExtensionsShellEx.dll needs to be registered in order to use the shell extensions."; bValid = false; } else { ShellExtensionsRegistered.BackColor = Color.LightGreen; ShellExtensionsRegistered.Text = "Shell extensions registered properly."; } GitCommands.GitCommands gitCommands = new GitCommands.GitCommands(); if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.name")) || string.IsNullOrEmpty(gitCommands.GetGlobalSetting("user.email"))) { UserNameSet.BackColor = Color.LightSalmon; UserNameSet.Text = "You need to configure a user name and an email address."; bValid = false; } else { UserNameSet.BackColor = Color.LightGreen; UserNameSet.Text = "There is a user name and an email address configured."; } if (string.IsNullOrEmpty(gitCommands.GetGlobalSetting("merge.tool"))) { DiffTool.BackColor = Color.LightSalmon; DiffTool.Text = "You need to configure merge tool in order to solve mergeconflicts (kdiff3 for example)."; bValid = false; } else { DiffTool.BackColor = Color.LightGreen; DiffTool.Text = "There is a mergetool configured."; } if (string.IsNullOrEmpty(GitCommands.GitCommands.RunCmd("git.cmd", "status"))) { GitFound.BackColor = Color.LightSalmon; GitFound.Text = "git.cmd needs to be in the system path. To solve this problem you can add git.cmd to the path or reinstall git."; bValid = false; } else { GitFound.BackColor = Color.LightGreen; GitFound.Text = "git.cmd is found on your computer."; } } catch { } if ((Application.UserAppDataRegistry.GetValue("checksettings") == null || Application.UserAppDataRegistry.GetValue("checksettings").ToString() == "true")) { CheckAtStartup.Checked = true; } else { CheckAtStartup.Checked = false; } return bValid; }