Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix most of toolbar functionality not working with auto-generated solutions such as CMake #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions TortoiseGitToolbar.Shared/Config/SettingsDialog.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
}
12 changes: 8 additions & 4 deletions TortoiseGitToolbar.Shared/Services/TortoiseGitLauncherService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,27 @@ public void ExecuteTortoiseProc(ToolbarCommand command)
return;
}

var preferredPath = Config.GlobalConfig.PreferFileOverSolution ? openedFilePath : solutionPath;


ProcessStartInfo process;
switch (command)
{
case ToolbarCommand.Bash:
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();
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Config\Constants\PathConfiguration.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Config\Constants\ToolbarCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Config\SettingsDialog.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Resources\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down
1 change: 1 addition & 0 deletions TortoiseGitToolbar.Shared/TortoiseGitToolbarPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TortoiseGitToolbar/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="f388ee16-eef2-4ae1-85bd-4cb19151beb0" Version="1.0.6" Language="en-US" Publisher="mdaviesnet" />
<Identity Id="f388ee16-eef2-4ae1-85bd-4cb19151beb0" Version="1.0.7" Language="en-US" Publisher="mdaviesnet" />
<DisplayName>TortoiseGit Toolbar</DisplayName>
<Description xml:space="preserve">Lightweight toolbar for launching commonly used TortoiseGit functionality from within Visual Studio.</Description>
<MoreInfo>https://github.com/MattDavies/TortoiseGitToolbar</MoreInfo>
Expand Down