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
+
+
+
+
+