From 8078428cdcba459249d3b8b62ea7a05b69ae50c9 Mon Sep 17 00:00:00 2001 From: "Samir L. Boulema" Date: Tue, 9 Aug 2016 16:10:54 +0200 Subject: [PATCH] #16: CloseOnEnd --- TGit/Commands/ContextMenuCommands.cs | 114 +++++++++---------- TGit/Commands/GitFlowCommands.cs | 4 +- TGit/Commands/MainMenuCommands.cs | 158 +++++++++++++-------------- TGit/Helpers/CommandHelper.cs | 4 +- TGit/{Options.cs => OptionsFlow.cs} | 17 +-- TGit/OptionsGeneral.cs | 30 +++++ TGit/TGIT.csproj | 5 +- TGit/TGITPackage.cs | 36 +++--- 8 files changed, 195 insertions(+), 173 deletions(-) rename TGit/{Options.cs => OptionsFlow.cs} (81%) create mode 100644 TGit/OptionsGeneral.cs diff --git a/TGit/Commands/ContextMenuCommands.cs b/TGit/Commands/ContextMenuCommands.cs index 30c0664..61c005f 100644 --- a/TGit/Commands/ContextMenuCommands.cs +++ b/TGit/Commands/ContextMenuCommands.cs @@ -8,126 +8,126 @@ namespace SamirBoulema.TGit.Commands { public class ContextMenuCommands { - private readonly ProcessHelper processHelper; - private readonly CommandHelper commandHelper; - private readonly FileHelper fileHelper; - private readonly GitHelper gitHelper; - private readonly DTE dte; - private readonly OptionPageGrid options; + private readonly ProcessHelper _processHelper; + private readonly CommandHelper _commandHelper; + private readonly FileHelper _fileHelper; + private readonly GitHelper _gitHelper; + private readonly DTE _dte; + private readonly OptionPageGrid _generalOptions; public ContextMenuCommands(ProcessHelper processHelper, CommandHelper commandHelper, GitHelper gitHelper, FileHelper fileHelper, - DTE dte, OptionPageGrid options) + DTE dte, OptionPageGrid generalOptions) { - this.processHelper = processHelper; - this.commandHelper = commandHelper; - this.gitHelper = gitHelper; - this.fileHelper = fileHelper; - this.dte = dte; - this.options = options; + _processHelper = processHelper; + _commandHelper = commandHelper; + _gitHelper = gitHelper; + _fileHelper = fileHelper; + _dte = dte; + _generalOptions = generalOptions; } public void AddCommands() { - commandHelper.AddCommand(ShowLogContextCommand, PkgCmdIDList.ShowLogContext); - commandHelper.AddCommand(DiskBrowserContextCommand, PkgCmdIDList.DiskBrowserContext); - commandHelper.AddCommand(RepoBrowserContextCommand, PkgCmdIDList.RepoBrowserContext); + _commandHelper.AddCommand(ShowLogContextCommand, PkgCmdIDList.ShowLogContext); + _commandHelper.AddCommand(DiskBrowserContextCommand, PkgCmdIDList.DiskBrowserContext); + _commandHelper.AddCommand(RepoBrowserContextCommand, PkgCmdIDList.RepoBrowserContext); - commandHelper.AddCommand(BlameContextCommand, PkgCmdIDList.BlameContext); + _commandHelper.AddCommand(BlameContextCommand, PkgCmdIDList.BlameContext); - commandHelper.AddCommand(MergeContextCommand, PkgCmdIDList.MergeContext); + _commandHelper.AddCommand(MergeContextCommand, PkgCmdIDList.MergeContext); - commandHelper.AddCommand(PullContextCommand, PkgCmdIDList.PullContext); - commandHelper.AddCommand(FetchContextCommand, PkgCmdIDList.FetchContext); - commandHelper.AddCommand(CommitContextCommand, PkgCmdIDList.CommitContext); - commandHelper.AddCommand(RevertContextCommand, PkgCmdIDList.RevertContext); - commandHelper.AddCommand(DiffContextCommand, PkgCmdIDList.DiffContext); - commandHelper.AddCommand(PrefDiffContextCommand, PkgCmdIDList.PrefDiffContext); + _commandHelper.AddCommand(PullContextCommand, PkgCmdIDList.PullContext); + _commandHelper.AddCommand(FetchContextCommand, PkgCmdIDList.FetchContext); + _commandHelper.AddCommand(CommitContextCommand, PkgCmdIDList.CommitContext); + _commandHelper.AddCommand(RevertContextCommand, PkgCmdIDList.RevertContext); + _commandHelper.AddCommand(DiffContextCommand, PkgCmdIDList.DiffContext); + _commandHelper.AddCommand(PrefDiffContextCommand, PkgCmdIDList.PrefDiffContext); } private void ShowLogContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:log /path:\"{currentFilePath}\" /closeonend:0"); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:log /path:\"{currentFilePath}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void DiskBrowserContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - processHelper.Start(currentFilePath); + _processHelper.Start(currentFilePath); } private void RepoBrowserContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - processHelper.StartTortoiseGitProc($"/command:repobrowser /path:\"{currentFilePath}\""); + _processHelper.StartTortoiseGitProc($"/command:repobrowser /path:\"{currentFilePath}\""); } private void BlameContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; - int currentLineIndex = ((TextDocument)dte.ActiveDocument.Object(string.Empty)).Selection.CurrentLine; + string currentFilePath = _dte.ActiveDocument.FullName; + int currentLineIndex = ((TextDocument)_dte.ActiveDocument.Object(string.Empty)).Selection.CurrentLine; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:blame /path:\"{currentFilePath}\" /line:{currentLineIndex}"); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:blame /path:\"{currentFilePath}\" /line:{currentLineIndex}"); } private void MergeContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:merge /path:\"{currentFilePath}\""); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:merge /path:\"{currentFilePath}\""); } private void PullContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:pull /path:\"{currentFilePath}\""); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:pull /path:\"{currentFilePath}\""); } private void FetchContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:fetch /path:\"{currentFilePath}\""); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:fetch /path:\"{currentFilePath}\""); } private void CommitContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:commit /path:\"{currentFilePath}\" /logmsg:\"{gitHelper.GetCommitMessage(options.CommitMessage, dte)}\" /closeonend:0"); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:commit /path:\"{currentFilePath}\" /logmsg:\"{_gitHelper.GetCommitMessage(_generalOptions.CommitMessage, _dte)}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void RevertContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:revert /path:\"{currentFilePath}\""); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:revert /path:\"{currentFilePath}\""); } private void DiffContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); - processHelper.StartTortoiseGitProc($"/command:diff /path:\"{currentFilePath}\""); + _dte.ActiveDocument.Save(); + _processHelper.StartTortoiseGitProc($"/command:diff /path:\"{currentFilePath}\""); } private void PrefDiffContextCommand(object sender, EventArgs e) { - string currentFilePath = dte.ActiveDocument.FullName; + string currentFilePath = _dte.ActiveDocument.FullName; if (string.IsNullOrEmpty(currentFilePath)) return; - dte.ActiveDocument.Save(); + _dte.ActiveDocument.Save(); - var revisions = processHelper.GitResult(Path.GetDirectoryName(currentFilePath), $"log -2 --pretty=format:%h {fileHelper.GetExactFileName(currentFilePath)}"); + var revisions = _processHelper.GitResult(Path.GetDirectoryName(currentFilePath), $"log -2 --pretty=format:%h {_fileHelper.GetExactFileName(currentFilePath)}"); if (!revisions.Contains(",")) { MessageBox.Show("Could not determine the last committed revision!", "TGit", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { - processHelper.StartTortoiseGitProc($"/command:diff /path:\"{fileHelper.GetExactPathName(currentFilePath)}\" /startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}"); + _processHelper.StartTortoiseGitProc($"/command:diff /path:\"{_fileHelper.GetExactPathName(currentFilePath)}\" /startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}"); } } } diff --git a/TGit/Commands/GitFlowCommands.cs b/TGit/Commands/GitFlowCommands.cs index 5cc3c45..9a25559 100644 --- a/TGit/Commands/GitFlowCommands.cs +++ b/TGit/Commands/GitFlowCommands.cs @@ -12,12 +12,12 @@ public class GitFlowCommands private readonly CommandHelper _commandHelper; private readonly FileHelper _fileHelper; private readonly GitHelper _gitHelper; - private readonly OptionPageGrid _options; + private readonly OptionFlowPageGrid _options; private readonly string _gitBin; private readonly OleMenuCommandService _mcs; public GitFlowCommands(ProcessHelper processHelper, CommandHelper commandHelper, GitHelper gitHelper, FileHelper fileHelper, - OptionPageGrid options, OleMenuCommandService mcs) + OptionFlowPageGrid options, OleMenuCommandService mcs) { _processHelper = processHelper; _commandHelper = commandHelper; diff --git a/TGit/Commands/MainMenuCommands.cs b/TGit/Commands/MainMenuCommands.cs index aa273f7..d6a4d9a 100644 --- a/TGit/Commands/MainMenuCommands.cs +++ b/TGit/Commands/MainMenuCommands.cs @@ -7,170 +7,170 @@ namespace SamirBoulema.TGit.Commands { public class MainMenuCommands { - private readonly ProcessHelper processHelper; - private readonly CommandHelper commandHelper; - private readonly FileHelper fileHelper; - private readonly GitHelper gitHelper; - private readonly DTE dte; - private readonly OptionPageGrid options; - private readonly OleMenuCommandService mcs; + private readonly ProcessHelper _processHelper; + private readonly CommandHelper _commandHelper; + private readonly FileHelper _fileHelper; + private readonly GitHelper _gitHelper; + private readonly DTE _dte; + private readonly OptionPageGrid _generalOptions; + private readonly OleMenuCommandService _mcs; public MainMenuCommands(ProcessHelper processHelper, CommandHelper commandHelper, GitHelper gitHelper, FileHelper fileHelper, - DTE dte, OptionPageGrid options, OleMenuCommandService mcs) + DTE dte, OptionPageGrid generalOptions, OleMenuCommandService mcs) { - this.processHelper = processHelper; - this.commandHelper = commandHelper; - this.gitHelper = gitHelper; - this.fileHelper = fileHelper; - this.dte = dte; - this.options = options; - this.mcs = mcs; + _processHelper = processHelper; + _commandHelper = commandHelper; + _gitHelper = gitHelper; + _fileHelper = fileHelper; + _dte = dte; + _generalOptions = generalOptions; + _mcs = mcs; } public void AddCommands() { - commandHelper.AddCommand(ShowChangesCommand, PkgCmdIDList.ShowChanges); - commandHelper.AddCommand(PullCommand, PkgCmdIDList.Pull); - commandHelper.AddCommand(FetchCommand, PkgCmdIDList.Fetch); - commandHelper.AddCommand(CommitCommand, PkgCmdIDList.Commit); + _commandHelper.AddCommand(ShowChangesCommand, PkgCmdIDList.ShowChanges); + _commandHelper.AddCommand(PullCommand, PkgCmdIDList.Pull); + _commandHelper.AddCommand(FetchCommand, PkgCmdIDList.Fetch); + _commandHelper.AddCommand(CommitCommand, PkgCmdIDList.Commit); //OleMenuCommand commit = commandHelper.CreateCommand(CommitCommand, PkgCmdIDList.Commit); //commit.BeforeQueryStatus += Diff_BeforeQueryStatus; //mcs.AddCommand(commit); - commandHelper.AddCommand(PushCommand, PkgCmdIDList.Push); + _commandHelper.AddCommand(PushCommand, PkgCmdIDList.Push); - commandHelper.AddCommand(ShowLogCommand, PkgCmdIDList.ShowLog); - commandHelper.AddCommand(DiskBrowserCommand, PkgCmdIDList.DiskBrowser); - commandHelper.AddCommand(RepoBrowserCommand, PkgCmdIDList.RepoBrowser); + _commandHelper.AddCommand(ShowLogCommand, PkgCmdIDList.ShowLog); + _commandHelper.AddCommand(DiskBrowserCommand, PkgCmdIDList.DiskBrowser); + _commandHelper.AddCommand(RepoBrowserCommand, PkgCmdIDList.RepoBrowser); - commandHelper.AddCommand(CreateStashCommand, PkgCmdIDList.CreateStash); - OleMenuCommand applyStash = commandHelper.CreateCommand(ApplyStashCommand, PkgCmdIDList.ApplyStash); - applyStash.BeforeQueryStatus += commandHelper.ApplyStash_BeforeQueryStatus; - mcs.AddCommand(applyStash); + _commandHelper.AddCommand(CreateStashCommand, PkgCmdIDList.CreateStash); + OleMenuCommand applyStash = _commandHelper.CreateCommand(ApplyStashCommand, PkgCmdIDList.ApplyStash); + applyStash.BeforeQueryStatus += _commandHelper.ApplyStash_BeforeQueryStatus; + _mcs.AddCommand(applyStash); - commandHelper.AddCommand(BranchCommand, PkgCmdIDList.Branch); - commandHelper.AddCommand(SwitchCommand, PkgCmdIDList.Switch); - commandHelper.AddCommand(MergeCommand, PkgCmdIDList.Merge); + _commandHelper.AddCommand(BranchCommand, PkgCmdIDList.Branch); + _commandHelper.AddCommand(SwitchCommand, PkgCmdIDList.Switch); + _commandHelper.AddCommand(MergeCommand, PkgCmdIDList.Merge); - commandHelper.AddCommand(RevertCommand, PkgCmdIDList.Revert); - commandHelper.AddCommand(ResolveCommand, PkgCmdIDList.Resolve); - commandHelper.AddCommand(SyncCommand, PkgCmdIDList.Sync); - commandHelper.AddCommand(CleanupCommand, PkgCmdIDList.Cleanup); + _commandHelper.AddCommand(RevertCommand, PkgCmdIDList.Revert); + _commandHelper.AddCommand(ResolveCommand, PkgCmdIDList.Resolve); + _commandHelper.AddCommand(SyncCommand, PkgCmdIDList.Sync); + _commandHelper.AddCommand(CleanupCommand, PkgCmdIDList.Cleanup); } private void ShowChangesCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:repostatus /path:\"{solutionDir}\" /closeonend:0"); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:repostatus /path:\"{solutionDir}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void PullCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:pull /path:\"{solutionDir}\" /closeonend:0"); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:pull /path:\"{solutionDir}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void FetchCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:fetch /path:\"{solutionDir}\" /closeonend:0"); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:fetch /path:\"{solutionDir}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void CommitCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc( - $"/command:commit /path:\"{solutionDir}\" /logmsg:\"{gitHelper.GetCommitMessage(options.CommitMessage, dte)}\" /closeonend:0"); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc( + $"/command:commit /path:\"{solutionDir}\" /logmsg:\"{_gitHelper.GetCommitMessage(_generalOptions.CommitMessage, _dte)}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void PushCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:push /path:\"{solutionDir}\" /closeonend:0"); + _processHelper.StartTortoiseGitProc($"/command:push /path:\"{solutionDir}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void ShowLogCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:log /path:\"{solutionDir}\" /closeonend:0"); + _processHelper.StartTortoiseGitProc($"/command:log /path:\"{solutionDir}\" /closeonend:{_generalOptions.CloseOnEnd}"); } private void DiskBrowserCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.Start(solutionDir); + _processHelper.Start(solutionDir); } private void RepoBrowserCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:repobrowser /path:\"{solutionDir}\""); + _processHelper.StartTortoiseGitProc($"/command:repobrowser /path:\"{solutionDir}\""); } private void CreateStashCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:stashsave /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:stashsave /path:\"{solutionDir}\""); } private void ApplyStashCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:reflog /ref:refs/stash /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:reflog /ref:refs/stash /path:\"{solutionDir}\""); } private void BranchCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:branch /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:branch /path:\"{solutionDir}\""); } private void SwitchCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:switch /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:switch /path:\"{solutionDir}\""); } private void MergeCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:merge /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:merge /path:\"{solutionDir}\""); } private void RevertCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - fileHelper.SaveAllFiles(); - processHelper.StartTortoiseGitProc($"/command:revert /path:\"{solutionDir}\""); + _fileHelper.SaveAllFiles(); + _processHelper.StartTortoiseGitProc($"/command:revert /path:\"{solutionDir}\""); } private void CleanupCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:cleanup /path:\"{solutionDir}\""); + _processHelper.StartTortoiseGitProc($"/command:cleanup /path:\"{solutionDir}\""); } private void ResolveCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:resolve /path:\"{solutionDir}\""); + _processHelper.StartTortoiseGitProc($"/command:resolve /path:\"{solutionDir}\""); } private void SyncCommand(object sender, EventArgs e) { - string solutionDir = fileHelper.GetSolutionDir(); + string solutionDir = _fileHelper.GetSolutionDir(); if (string.IsNullOrEmpty(solutionDir)) return; - processHelper.StartTortoiseGitProc($"/command:sync /path:\"{solutionDir}\""); + _processHelper.StartTortoiseGitProc($"/command:sync /path:\"{solutionDir}\""); } } } diff --git a/TGit/Helpers/CommandHelper.cs b/TGit/Helpers/CommandHelper.cs index 9fb62d8..93617c0 100644 --- a/TGit/Helpers/CommandHelper.cs +++ b/TGit/Helpers/CommandHelper.cs @@ -10,9 +10,9 @@ public class CommandHelper private readonly FileHelper fileHelper; private readonly GitHelper gitHelper; private readonly OleMenuCommandService mcs; - private readonly OptionPageGrid options; + private readonly OptionFlowPageGrid options; - public CommandHelper(ProcessHelper processHelper, FileHelper fileHelper, GitHelper gitHelper, OleMenuCommandService mcs, OptionPageGrid options) + public CommandHelper(ProcessHelper processHelper, FileHelper fileHelper, GitHelper gitHelper, OleMenuCommandService mcs, OptionFlowPageGrid options) { this.processHelper = processHelper; this.fileHelper = fileHelper; diff --git a/TGit/Options.cs b/TGit/OptionsFlow.cs similarity index 81% rename from TGit/Options.cs rename to TGit/OptionsFlow.cs index 5988cd5..6a7b6b6 100644 --- a/TGit/Options.cs +++ b/TGit/OptionsFlow.cs @@ -7,7 +7,7 @@ namespace SamirBoulema.TGit { [ClassInterface(ClassInterfaceType.AutoDual)] [CLSCompliant(false), ComVisible(true)] - public class OptionPageGrid : DialogPage + public class OptionFlowPageGrid : DialogPage { private string _developBranch { get; set; } [Category("TGit")] @@ -50,7 +50,7 @@ public string ReleaseBranch private string _masterBranch { get; set; } [Category("TGit")] - [DisplayName(@"Master branches prefix")] + [DisplayName(@"Master branch prefix")] [Description("Prefix for your Gitflow master branch")] public string MasterBranch { @@ -73,18 +73,5 @@ public string HotfixBranch } set { _hotfixBranch = value; } } - - private string _commitMessage { get; set; } - [Category("TGit")] - [DisplayName(@"Default commit message")] - [Description("$(BranchName), $(FeatureName), https://msdn.microsoft.com/en-us/library/c02as0cs.aspx")] - public string CommitMessage - { - get - { - return _commitMessage ?? string.Empty; - } - set { _commitMessage = value; } - } } } diff --git a/TGit/OptionsGeneral.cs b/TGit/OptionsGeneral.cs new file mode 100644 index 0000000..c608091 --- /dev/null +++ b/TGit/OptionsGeneral.cs @@ -0,0 +1,30 @@ +using Microsoft.VisualStudio.Shell; +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +namespace SamirBoulema.TGit +{ + [ClassInterface(ClassInterfaceType.AutoDual)] + [CLSCompliant(false), ComVisible(true)] + public class OptionPageGrid : DialogPage + { + private string _commitMessage { get; set; } + [Category("TGit")] + [DisplayName(@"Default commit message")] + [Description("$(BranchName), $(FeatureName), https://msdn.microsoft.com/en-us/library/c02as0cs.aspx")] + public string CommitMessage + { + get + { + return _commitMessage ?? string.Empty; + } + set { _commitMessage = value; } + } + + [Category("TGit")] + [DisplayName(@"Close dialog after operation")] + [Description("0: Close manually, 1: Auto-close if no further options are available, 2: Auto-close if no errors")] + public int CloseOnEnd { get; set; } + } +} diff --git a/TGit/TGIT.csproj b/TGit/TGIT.csproj index d6a5e21..22b7ab1 100644 --- a/TGit/TGIT.csproj +++ b/TGit/TGIT.csproj @@ -157,7 +157,10 @@ - + + Component + + Component diff --git a/TGit/TGITPackage.cs b/TGit/TGITPackage.cs index c498e33..b6dcec2 100644 --- a/TGit/TGITPackage.cs +++ b/TGit/TGITPackage.cs @@ -14,10 +14,11 @@ namespace SamirBoulema.TGit [Guid(GuidList.GuidTgitPkgString)] [ProvideAutoLoad(UIContextGuids80.NoSolution)] [ProvideOptionPage(typeof(OptionPageGrid), "TGit", "General", 0, 0, true)] + [ProvideOptionPage(typeof(OptionFlowPageGrid), "TGit", "Flow", 0, 0, true)] public sealed class TGitPackage : Package { - private DTE dte; - private OptionPageGrid options; + private DTE _dte; + private OptionFlowPageGrid _options; private FileHelper fileHelper; private ProcessHelper processHelper; private CommandHelper commandHelper; @@ -31,28 +32,29 @@ protected override void Initialize() { base.Initialize(); - dte = (DTE)GetService(typeof(DTE)); - options = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)); - fileHelper = new FileHelper(dte); - processHelper = new ProcessHelper(dte); - gitHelper = new GitHelper(fileHelper, processHelper, options.FeatureBranch, options.ReleaseBranch, options.HotfixBranch); + _dte = (DTE)GetService(typeof(DTE)); + _options = (OptionFlowPageGrid)GetDialogPage(typeof(OptionFlowPageGrid)); + var generalOptions = (OptionPageGrid)GetDialogPage(typeof(OptionPageGrid)); + fileHelper = new FileHelper(_dte); + processHelper = new ProcessHelper(_dte); + gitHelper = new GitHelper(fileHelper, processHelper, _options.FeatureBranch, _options.ReleaseBranch, _options.HotfixBranch); // Add our command handlers for menu (commands must exist in the .vsct file) - OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null == mcs) return; - commandHelper = new CommandHelper(processHelper, fileHelper, gitHelper, mcs, options); + commandHelper = new CommandHelper(processHelper, fileHelper, gitHelper, mcs, _options); - new MainMenuCommands(processHelper, commandHelper, gitHelper, fileHelper, dte, options, mcs).AddCommands(); + new MainMenuCommands(processHelper, commandHelper, gitHelper, fileHelper, _dte, generalOptions, mcs).AddCommands(); - new ContextMenuCommands(processHelper, commandHelper, gitHelper, fileHelper, dte, options).AddCommands(); + new ContextMenuCommands(processHelper, commandHelper, gitHelper, fileHelper, _dte, generalOptions).AddCommands(); - new GitFlowCommands(processHelper, commandHelper, gitHelper, fileHelper, options, mcs).AddCommands(); + new GitFlowCommands(processHelper, commandHelper, gitHelper, fileHelper, _options, mcs).AddCommands(); // Add all menus - OleMenuCommand tgitMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitMenu); - OleMenuCommand tgitContextMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitContextMenu); - switch (dte.Version) + var tgitMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitMenu); + var tgitContextMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitContextMenu); + switch (_dte.Version) { case "11.0": case "12.0": @@ -67,11 +69,11 @@ protected override void Initialize() mcs.AddCommand(tgitMenu); mcs.AddCommand(tgitContextMenu); - OleMenuCommand tgitGitFlowMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitGitFlowMenu); + var tgitGitFlowMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitGitFlowMenu); tgitGitFlowMenu.BeforeQueryStatus += commandHelper.GitFlow_BeforeQueryStatus; mcs.AddCommand(tgitGitFlowMenu); - OleMenuCommand tgitGitHubFlowMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitGitHubFlowMenu); + var tgitGitHubFlowMenu = commandHelper.CreateCommand(PkgCmdIDList.TGitGitHubFlowMenu); tgitGitHubFlowMenu.BeforeQueryStatus += commandHelper.GitHubFlow_BeforeQueryStatus; mcs.AddCommand(tgitGitHubFlowMenu); }