Skip to content

Commit

Permalink
Toolbar redraw issue. Refactor getting git root dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Dec 14, 2018
1 parent 2d199dd commit 37c3d62
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 143 deletions.
23 changes: 12 additions & 11 deletions TGit/Commands/ContextMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void ShowLogContextCommand(object sender, EventArgs e)
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:log /path:\"{currentFilePath}\" /closeonend:{_generalOptions.CloseOnEnd}");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:log /closeonend:{_generalOptions.CloseOnEnd}", currentFilePath);
}
private void DiskBrowserContextCommand(object sender, EventArgs e)
{
Expand All @@ -62,7 +62,7 @@ private void RepoBrowserContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:repobrowser /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:repobrowser", currentFilePath);
}
private void BlameContextCommand(object sender, EventArgs e)
{
Expand All @@ -71,31 +71,31 @@ private void BlameContextCommand(object sender, EventArgs e)
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:blame /path:\"{currentFilePath}\" /line:{currentLineIndex}");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:blame /line:{currentLineIndex}", currentFilePath);
}
private void MergeContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:merge /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:merge", currentFilePath);
}
private void PullContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:pull /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:pull", currentFilePath);
}
private void FetchContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:fetch /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:fetch", currentFilePath);
}
private void CommitContextCommand(object sender, EventArgs e)
{
Expand All @@ -107,26 +107,26 @@ private void CommitContextCommand(object sender, EventArgs e)
var bugId = GitHelper.GetCommitMessage(_generalOptions.BugId, _dte, _envHelper);
var gitConfig = GitHelper.GetGitConfig(_envHelper);

ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:commit /path:\"{currentFilePath}\" " +
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:commit " +
$"{(string.IsNullOrEmpty(commitMessage) ? string.Empty : $"/logmsg:\"{commitMessage}\"")} " +
$"{(!string.IsNullOrEmpty(bugId) && !string.IsNullOrEmpty(gitConfig.BugTraqMessage) ? $"/bugid:\"{bugId}\"" : string.Empty)} " +
$"/closeonend:{_generalOptions.CloseOnEnd}");
$"/closeonend:{_generalOptions.CloseOnEnd}", currentFilePath);
}
private void RevertContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:revert /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:revert", currentFilePath);
}
private void DiffContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:diff /path:\"{currentFilePath}\"");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:diff", currentFilePath);
}

private void PrefDiffContextCommand(object sender, EventArgs e)
Expand All @@ -145,7 +145,8 @@ private void PrefDiffContextCommand(object sender, EventArgs e)
else
{
ProcessHelper.StartTortoiseGitProc(_envHelper,
$"/command:diff /path:\"{FileHelper.GetExactPathName(currentFilePath)}\" /startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}");
$"/command:diff /startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}",
FileHelper.GetExactPathName(currentFilePath));
}
}
}
Expand Down
53 changes: 35 additions & 18 deletions TGit/Commands/GitFlowMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void AddCommands()

private void InitCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var flowDialog = new FlowDialog();
if (flowDialog.ShowDialog() != DialogResult.OK) return;
Expand All @@ -83,7 +84,7 @@ private void InitCommand(object sender, EventArgs e)
*/
var process = ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"config --add gitflow.branch.master {flowDialog.GitConfig.MasterBranch}") +
FormatCliCommand($"config --add gitflow.branch.develop {flowDialog.GitConfig.DevelopBranch}") +
Expand All @@ -103,7 +104,9 @@ private void InitCommand(object sender, EventArgs e)

private void StartFeatureCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var featureName = Interaction.InputBox("Feature Name:", "Start New Feature");
if (string.IsNullOrEmpty(featureName)) return;

Expand All @@ -115,7 +118,7 @@ private void StartFeatureCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {flowOptions.DevelopBranch}") +
FormatCliCommand("pull") +
Expand All @@ -126,7 +129,9 @@ private void StartFeatureCommand(object sender, EventArgs e)

private void StartFeatureGitHubCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var featureName = Interaction.InputBox("Feature Name:", "Start New Feature");
if (string.IsNullOrEmpty(featureName)) return;

Expand All @@ -136,7 +141,7 @@ private void StartFeatureGitHubCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand("checkout master") +
FormatCliCommand("pull") +
Expand All @@ -147,7 +152,9 @@ private void StartFeatureGitHubCommand(object sender, EventArgs e)

private void FinishFeatureCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var featureBranch = GitHelper.GetCurrentBranchName(false, _envHelper);
var featureName = GitHelper.GetCurrentBranchName(true, _envHelper);
var gitConfig = GitHelper.GetGitConfig(_envHelper);
Expand All @@ -161,7 +168,7 @@ private void FinishFeatureCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {gitConfig.DevelopBranch}") +
FormatCliCommand("pull") +
Expand All @@ -179,7 +186,9 @@ private string FormatCliCommand(string gitCommand, bool appendNextLine = true)

private void FinishFeatureGitHubCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var featureBranch = GitHelper.GetCurrentBranchName(false, _envHelper);
var featureName = GitHelper.GetCurrentBranchName(true, _envHelper);

Expand All @@ -192,7 +201,7 @@ private void FinishFeatureGitHubCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand("checkout master") +
FormatCliCommand("pull") +
Expand All @@ -203,7 +212,9 @@ private void FinishFeatureGitHubCommand(object sender, EventArgs e)

private void StartReleaseCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var releaseVersion = Interaction.InputBox("Release Version:", "Start New Release");
if (string.IsNullOrEmpty(releaseVersion)) return;

Expand All @@ -215,7 +226,7 @@ private void StartReleaseCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {flowOptions.DevelopBranch}") +
FormatCliCommand("pull") +
Expand All @@ -226,7 +237,9 @@ private void StartReleaseCommand(object sender, EventArgs e)

private void FinishReleaseCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var releaseBranch = GitHelper.GetCurrentBranchName(false, _envHelper);
var releaseName = GitHelper.GetCurrentBranchName(true, _envHelper);
var gitConfig = GitHelper.GetGitConfig(_envHelper);
Expand All @@ -246,7 +259,7 @@ private void FinishReleaseCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {gitConfig.MasterBranch}") +
FormatCliCommand("pull") +
Expand All @@ -265,7 +278,9 @@ private void FinishReleaseCommand(object sender, EventArgs e)

private void StartHotfixCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var hotfixVersion = Interaction.InputBox("Hotfix Version:", "Start New Hotfix");
if (string.IsNullOrEmpty(hotfixVersion)) return;

Expand All @@ -277,7 +292,7 @@ private void StartHotfixCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {flowOptions.MasterBranch}") +
FormatCliCommand("pull") +
Expand All @@ -288,7 +303,9 @@ private void StartHotfixCommand(object sender, EventArgs e)

private void FinishHotfixCommand(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(_envHelper.GetSolutionDir())) return;
var rootDir = _envHelper.GetGitRoot();
if (string.IsNullOrEmpty(rootDir)) return;

var hotfixBranch = GitHelper.GetCurrentBranchName(false, _envHelper);
var hotfixName = GitHelper.GetCurrentBranchName(true, _envHelper);
var gitConfig = GitHelper.GetGitConfig(_envHelper);
Expand All @@ -308,7 +325,7 @@ private void FinishHotfixCommand(object sender, EventArgs e)
*/
ProcessHelper.StartProcessGui(_dte, _envHelper,
"cmd.exe",
$"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
$"/c cd \"{rootDir}\" && " +
GitHelper.GetSshSetup(_envHelper) +
FormatCliCommand($"checkout {gitConfig.MasterBranch}") +
FormatCliCommand("pull") +
Expand Down
6 changes: 3 additions & 3 deletions TGit/Commands/GitSVNMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ public void AddCommands()
private void SvnDCommitCommand(object sender, EventArgs e)
{
FileHelper.SaveAllFiles(_dte);
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svndcommit /path:\"{_envHelper.GetSolutionDir()}\" /closeonend:{_options.CloseOnEnd}");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svndcommit /path:\"{_envHelper.GetGitRoot()}\" /closeonend:{_options.CloseOnEnd}");
}

private void SvnFetchCommand(object sender, EventArgs e)
{
FileHelper.SaveAllFiles(_dte);
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svnrebase /path:\"{_envHelper.GetSolutionDir()}\" /closeonend:{_options.CloseOnEnd}");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svnrebase /path:\"{_envHelper.GetGitRoot()}\" /closeonend:{_options.CloseOnEnd}");
}

private void SvnRebaseCommand(object sender, EventArgs e)
{
FileHelper.SaveAllFiles(_dte);
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svnfetch /path:\"{_envHelper.GetSolutionDir()}\" /closeonend:{_options.CloseOnEnd}");
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:svnfetch /path:\"{_envHelper.GetGitRoot()}\" /closeonend:{_options.CloseOnEnd}");
}
}
}
Loading

0 comments on commit 37c3d62

Please sign in to comment.