diff --git a/TortoiseGitToolbar.Shared/Config/SettingsDialog.cs b/TortoiseGitToolbar.Shared/Config/SettingsDialog.cs new file mode 100644 index 0000000..322d816 --- /dev/null +++ b/TortoiseGitToolbar.Shared/Config/SettingsDialog.cs @@ -0,0 +1,39 @@ +using EnvDTE; +using Microsoft.VisualStudio.OLE.Interop; +using Microsoft.VisualStudio.Shell; +using System; +using System.ComponentModel; +using System.ComponentModel.Design.Serialization; +using System.IO; +using System.Windows.Forms; + +namespace MattDavies.TortoiseGitToolbar.Config +{ + + public static partial class GlobalConfig + { + // enabled when the user knows that the solution directory is not + // trustworthy and the Active File path should be used in place of it + // where applicable. Typically if the source files are known to not exist + // as a child to the current solution. + public static bool PreferFileOverSolution { get; set; } = false; + public const string ExtensionName = "Tortoise Git Toolbar"; + } + + public class SettingsDialog : DialogPage + { + + private static SettingsDialog _instance { get; set; } = new SettingsDialog(); + public SettingsDialog Instance() => _instance; + + [Category("Paths and Directories")] + [DisplayName("Prefer File over Solution")] + [Description("Enable this option if you know your source files will not exist within the solution directory. Useful" + + " for when using generated solution files like the ones generated by CMake. ")] + public bool RootDirectory + { + get { return GlobalConfig.PreferFileOverSolution; } + set { GlobalConfig.PreferFileOverSolution = value; } + } + } +} \ No newline at end of file diff --git a/TortoiseGitToolbar.Shared/Services/TortoiseGitLauncherService.cs b/TortoiseGitToolbar.Shared/Services/TortoiseGitLauncherService.cs index 65c4a3c..6627619 100644 --- a/TortoiseGitToolbar.Shared/Services/TortoiseGitLauncherService.cs +++ b/TortoiseGitToolbar.Shared/Services/TortoiseGitLauncherService.cs @@ -59,6 +59,9 @@ public void ExecuteTortoiseProc(ToolbarCommand command) return; } + var preferredPath = Config.GlobalConfig.PreferFileOverSolution ? openedFilePath : solutionPath; + + ProcessStartInfo process; switch (command) { @@ -66,16 +69,17 @@ public void ExecuteTortoiseProc(ToolbarCommand command) process = _processManagerService.GetProcess( PathConfiguration.GetGitBashPath(), "--login -i", - solutionPath + preferredPath ); break; case ToolbarCommand.RebaseContinue: process = _processManagerService.GetProcess( PathConfiguration.GetGitBashPath(), @"--login -i -c 'echo; echo ""Running git rebase --continue""; echo; git rebase --continue; echo; echo ""Please review the output above and press enter to continue.""; read'", - solutionPath + preferredPath ); break; + case ToolbarCommand.Log: case ToolbarCommand.FileLog: case ToolbarCommand.FileDiff: var commandParam = command.ToString().Replace("File", string.Empty).ToLower(); @@ -94,13 +98,13 @@ public void ExecuteTortoiseProc(ToolbarCommand command) case ToolbarCommand.StashList: process = _processManagerService.GetProcess( PathConfiguration.GetTortoiseGitPath(), - string.Format(@"/command:reflog /path:""{0}"" /ref:""refs/stash""", solutionPath) + string.Format(@"/command:reflog /path:""{0}"" /ref:""refs/stash""", preferredPath) ); break; default: process = _processManagerService.GetProcess( PathConfiguration.GetTortoiseGitPath(), - string.Format(@"/command:{0} /path:""{1}""", command.ToString().ToLower(), solutionPath) + string.Format(@"/command:{0} /path:""{1}""", command.ToString().ToLower(), preferredPath) ); break; } diff --git a/TortoiseGitToolbar.Shared/TortoiseGitToolbar.Shared.projitems b/TortoiseGitToolbar.Shared/TortoiseGitToolbar.Shared.projitems index 756ca44..dad08d9 100644 --- a/TortoiseGitToolbar.Shared/TortoiseGitToolbar.Shared.projitems +++ b/TortoiseGitToolbar.Shared/TortoiseGitToolbar.Shared.projitems @@ -11,6 +11,7 @@ + True True diff --git a/TortoiseGitToolbar.Shared/TortoiseGitToolbarPackage.cs b/TortoiseGitToolbar.Shared/TortoiseGitToolbarPackage.cs index 479fb51..ee7ffff 100644 --- a/TortoiseGitToolbar.Shared/TortoiseGitToolbarPackage.cs +++ b/TortoiseGitToolbar.Shared/TortoiseGitToolbarPackage.cs @@ -14,6 +14,7 @@ namespace MattDavies.TortoiseGitToolbar [ProvideMenuResource("Menus.ctmenu", 1)] [Guid(PackageConstants.GuidTortoiseGitToolbarPkgString)] [ProvideKeyBindingTable(PackageConstants.GuidTortoiseGitToolbarPkgString, 110)] + [ProvideOptionPage(typeof(Config.SettingsDialog), Config.GlobalConfig.ExtensionName, "General", 0, 0, true)] public sealed class TortoiseGitToolbarPackage : Package { private OleMenuCommandService _commandService; diff --git a/TortoiseGitToolbar/source.extension.vsixmanifest b/TortoiseGitToolbar/source.extension.vsixmanifest index e6ba58a..59b42ee 100644 --- a/TortoiseGitToolbar/source.extension.vsixmanifest +++ b/TortoiseGitToolbar/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + TortoiseGit Toolbar Lightweight toolbar for launching commonly used TortoiseGit functionality from within Visual Studio. https://github.com/MattDavies/TortoiseGitToolbar