Skip to content

Commit

Permalink
Fix AsyncPackage Take2
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Jun 12, 2018
1 parent e80cc28 commit d37ecf3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
3 changes: 2 additions & 1 deletion TGit/Commands/GitFlowMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ private void FinishFeatureCommand(object sender, EventArgs e)

private string FormatCliCommand(string gitCommand, bool appendNextLine = true)
{
return $"echo ^> {Path.GetFileNameWithoutExtension(EnvHelper.Git)} {gitCommand} && \"{EnvHelper.Git}\" {gitCommand}{(appendNextLine ? " && " : string.Empty)}";
var git = EnvHelper.GetGit();
return $"echo ^> {Path.GetFileNameWithoutExtension(git)} {gitCommand} && \"{git}\" {gitCommand}{(appendNextLine ? " && " : string.Empty)}";
}

private void FinishFeatureGitHubCommand(object sender, EventArgs e)
Expand Down
26 changes: 20 additions & 6 deletions TGit/Helpers/EnvHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public static class EnvHelper
{
public static string BranchName;
private static string _solutionDir;
public static string TortoiseGitProc;
public static string Git;
private static string _tortoiseGitProc;
private static string _git;
public static DTE Dte;

public static bool IsGitFlow(DTE dte = null)
Expand Down Expand Up @@ -42,18 +42,32 @@ public static bool HasStash(DTE dte = null)
return ProcessHelper.StartProcessGit(dte, "stash list");
}

public static void GetTortoiseGitProc() => TortoiseGitProc = FileHelper.GetTortoiseGitProc();
public static string GetTortoiseGitProc()
{
if (string.IsNullOrEmpty(_tortoiseGitProc))
{
_tortoiseGitProc = FileHelper.GetTortoiseGitProc();
}
return _tortoiseGitProc;
}

public static void GetGit() => Git = FileHelper.GetMSysGit();
public static string GetGit()
{
if (string.IsNullOrEmpty(_git))
{
_git = FileHelper.GetMSysGit();
}
return _git;
}

public static bool HasSolutionDir(DTE dte = null) => !string.IsNullOrEmpty(GetSolutionDir(dte));

public static void Clear()
{
BranchName = string.Empty;
_solutionDir = string.Empty;
TortoiseGitProc = string.Empty;
Git = string.Empty;
_tortoiseGitProc = string.Empty;
_git = string.Empty;
}
}
}
11 changes: 6 additions & 5 deletions TGit/Helpers/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static bool StartProcessGit(DTE dte, string commands, bool showAlert = tr
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c cd /D \"{EnvHelper.GetSolutionDir(dte)}\" && \"{EnvHelper.Git}\" {commands}",
Arguments = $"/c cd /D \"{EnvHelper.GetSolutionDir(dte)}\" && \"{EnvHelper.GetGit()}\" {commands}",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand Down Expand Up @@ -57,13 +57,14 @@ public static bool StartProcessGit(DTE dte, string commands, bool showAlert = tr

public static void StartTortoiseGitProc(string args)
{
var tortoiseGitProc = EnvHelper.GetTortoiseGitProc();
try
{
Process.Start(EnvHelper.TortoiseGitProc, args);
Process.Start(tortoiseGitProc, args);
}
catch (Exception e)
{
MessageBox.Show(e.Message, $"{EnvHelper.TortoiseGitProc} not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(e.Message, $"{tortoiseGitProc} not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand All @@ -83,7 +84,7 @@ public static string StartProcessGitResult(DTE dte, string commands)
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c cd /D \"{EnvHelper.GetSolutionDir(dte)}\" && \"{EnvHelper.Git}\" {commands}",
Arguments = $"/c cd /D \"{EnvHelper.GetSolutionDir(dte)}\" && \"{EnvHelper.GetGit()}\" {commands}",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand Down Expand Up @@ -112,7 +113,7 @@ public static string GitResult(string workingDir, string commands)
StartInfo = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c cd /D \"{workingDir}\" && \"{EnvHelper.Git}\" {commands}",
Arguments = $"/c cd /D \"{workingDir}\" && \"{EnvHelper.GetGit()}\" {commands}",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand Down

0 comments on commit d37ecf3

Please sign in to comment.