diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e937c48..98b26a6 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -7,7 +7,7 @@ on: - 'feature/**' env: - version: '5.1.${{ github.run_number }}' + version: '5.2.${{ github.run_number }}' repoUrl: ${{ github.server_url }}/${{ github.repository }} jobs: diff --git a/TGit/Helpers/FileHelper.cs b/TGit/Helpers/FileHelper.cs index f1bec51..4e5951f 100644 --- a/TGit/Helpers/FileHelper.cs +++ b/TGit/Helpers/FileHelper.cs @@ -12,18 +12,17 @@ namespace SamirBoulema.TGit.Helpers public static class FileHelper { public static string GetTortoiseGitProc() - { - return (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\TortoiseGit", "ProcPath", @"C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe"); - } + => (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\TortoiseGit", + "ProcPath", @"C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe"); public static string GetTortoiseGitPlink() - { - return (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\TortoiseGit", "ProcPath", @"C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe"); - } + => (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\TortoiseGit", + "ProcPath", @"C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe"); public static string GetMSysGit() { - var regPath = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\TortoiseGit", "MSysGit", @"C:\Program Files (x86)\Git\bin\git.exe"); + var regPath = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\TortoiseGit", + "MSysGit", @"C:\Program Files (x86)\Git\bin\git.exe"); return Path.Combine(regPath, "git.exe"); } @@ -146,8 +145,35 @@ public static string GetExactPathName(string pathName) return di.Name.ToUpper(); } + /// + /// Get the path of the file on which to act upon. + /// This can be different depending on where the TGit context menu was used + /// + /// File path public static async Task GetActiveDocumentFilePath() { + var windowFrame = await VS.Windows.GetCurrentWindowAsync(); + var solutionExplorerIsActive = windowFrame.Guid == new Guid(WindowGuids.SolutionExplorer); + + // Context menu in the Solution Explorer + if (solutionExplorerIsActive) + { + var selectedItem = await VS.Solutions.GetActiveItemAsync(); + + if (selectedItem != null) + { + if (selectedItem.Type == SolutionItemType.Project || + selectedItem.Type == SolutionItemType.Solution) + { + return Path.GetDirectoryName(selectedItem.FullPath); + } + else if (selectedItem.Type == SolutionItemType.PhysicalFile) + { + return selectedItem.FullPath; + } + } + } + var documentView = await VS.Documents.GetActiveDocumentViewAsync(); return documentView?.FilePath; } diff --git a/TGit/TGIT.vsct b/TGit/TGIT.vsct index b9c58ec..d71d383 100644 --- a/TGit/TGIT.vsct +++ b/TGit/TGIT.vsct @@ -22,6 +22,26 @@ TGit + + + + + + TGit + + + + + + TGit + + + + + + TGit + + @@ -144,6 +164,16 @@ + + + + + + + + + + @@ -585,6 +615,11 @@ + + + + + diff --git a/TGit/TGit.cs b/TGit/TGit.cs index 5b0757d..f10ae48 100644 --- a/TGit/TGit.cs +++ b/TGit/TGit.cs @@ -15,6 +15,9 @@ internal sealed partial class PackageGuids public const string guidImagesString = "fec49b6d-c04a-42bd-b021-b8b2e5cfb291"; public static Guid guidImages = new Guid(guidImagesString); + public const string guidWorkspaceExplorerToolWindowCmdSetString = "cfb400f1-5c60-4f3c-856e-180d28def0b7"; + public static Guid guidWorkspaceExplorerToolWindowCmdSet = new Guid(guidWorkspaceExplorerToolWindowCmdSetString); + public const string HTMLContextString = "78f03954-2fb8-4087-8ce7-59d71710b3bb"; public static Guid HTMLContext = new Guid(HTMLContextString); @@ -60,6 +63,7 @@ internal sealed partial class PackageIds public const int revgraph = 0x0017; public const int config = 0x0018; public const int add = 0x0019; + public const int idmWSE_ContextMenu = 0x0002; public const int HTMLContextMenu = 0x0001; public const int CSSContextMenu = 0x0002; public const int ASPXContextMenu = 0x0035; diff --git a/TGit/TGit.csproj b/TGit/TGit.csproj index 8fe088d..5edb699 100644 --- a/TGit/TGit.csproj +++ b/TGit/TGit.csproj @@ -350,8 +350,8 @@ - - 15.0.76.304 + + 15.0.339 16.0.29.6 @@ -359,7 +359,7 @@ all - 17.0.4207-preview4 + 17.0.5232 runtime; build; native; contentfiles; analyzers; buildtransitive all