diff --git a/TGit/Commands/GitFlowMenuCommands.cs b/TGit/Commands/GitFlowMenuCommands.cs index 1567e60..c89671e 100644 --- a/TGit/Commands/GitFlowMenuCommands.cs +++ b/TGit/Commands/GitFlowMenuCommands.cs @@ -72,7 +72,7 @@ private void InitCommand(object sender, EventArgs e) * 2. Checkout develop branch (create if it doesn't exist, reset if it does) * 3. Push develop branch */ - ProcessHelper.StartProcessGui( + var process = ProcessHelper.StartProcessGui( "cmd.exe", $"/c cd \"{EnvHelper.SolutionDir}\" && " + GitHelper.GetSshSetup() + @@ -86,6 +86,8 @@ private void InitCommand(object sender, EventArgs e) FormatCliCommand($"checkout -b {flowDialog.FlowOptions.DevelopBranch}", false)), "Initializing GitFlow" ); + process.WaitForExit(); + EnvHelper.GetFlowOptions(); EnvHelper.GetBranchName(); } @@ -154,10 +156,9 @@ private void FinishFeatureCommand(object sender, EventArgs e) GitHelper.GetSshSetup() + FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand("pull") + - FormatCliCommand($"merge --no-ff {featureBranch}") + - FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}", false), + FormatCliCommand($"merge --no-ff {featureBranch}", false), $"Finishing feature {featureName}", - featureBranch, null, _options + featureBranch, null, _options, FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}") ); } @@ -185,10 +186,9 @@ private void FinishFeatureGitHubCommand(object sender, EventArgs e) GitHelper.GetSshSetup() + FormatCliCommand("checkout master") + FormatCliCommand("pull") + - FormatCliCommand($"merge --no-ff {featureBranch}") + - FormatCliCommand("push origin master", false), + FormatCliCommand($"merge --no-ff {featureBranch}", false), $"Finishing feature {featureName}", - featureBranch, null, _options); + featureBranch, null, _options, FormatCliCommand("push origin master")); } private void StartReleaseCommand(object sender, EventArgs e) @@ -244,12 +244,12 @@ private void FinishReleaseCommand(object sender, EventArgs e) FormatCliCommand($"tag {releaseName}") + FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand("pull") + - FormatCliCommand($"merge --no-ff {releaseBranch}") + + FormatCliCommand($"merge --no-ff {releaseBranch}", false), + $"Finishing release {releaseName}", + releaseBranch, null, _options, FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand($"push origin {EnvHelper.FlowOptions.MasterBranch}") + - FormatCliCommand($"push origin {releaseName}", false), - $"Finishing release {releaseName}", - releaseBranch, null, _options + FormatCliCommand($"push origin {releaseName}") ); } @@ -306,12 +306,12 @@ private void FinishHotfixCommand(object sender, EventArgs e) FormatCliCommand($"tag {hotfixName}") + FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand("pull") + - FormatCliCommand($"merge --no-ff {hotfixBranch}") + + FormatCliCommand($"merge --no-ff {hotfixBranch}", false), + $"Finishing hotfix {hotfixName}", + hotfixBranch, null, _options, FormatCliCommand($"push origin {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand($"push origin {EnvHelper.FlowOptions.MasterBranch}") + - FormatCliCommand($"push origin {hotfixName}", false), - $"Finishing hotfix {hotfixName}", - hotfixBranch, null, _options + FormatCliCommand($"push origin {hotfixName}") ); } } diff --git a/TGit/Helpers/ProcessHelper.cs b/TGit/Helpers/ProcessHelper.cs index cb1e8bd..48b7e70 100644 --- a/TGit/Helpers/ProcessHelper.cs +++ b/TGit/Helpers/ProcessHelper.cs @@ -142,7 +142,7 @@ public static void Start(string application, string arguments) } public static Process StartProcessGui(string application, string args, string title, string branchName = "", - OutputBox outputBox = null, OptionPageGrid options = null) + OutputBox outputBox = null, OptionPageGrid options = null, string pushCommand = "") { var dialogResult = DialogResult.OK; if (!StartProcessGit("config user.name") || !StartProcessGit("config user.email")) @@ -175,7 +175,7 @@ public static Process StartProcessGui(string application, string args, string ti if (outputBox == null) { - _outputBox = new OutputBox(branchName, options); + _outputBox = new OutputBox(branchName, options, pushCommand); _outputBox.Show(); } else diff --git a/TGit/OptionsGeneral.cs b/TGit/OptionsGeneral.cs index 4bf006f..2ebdff7 100644 --- a/TGit/OptionsGeneral.cs +++ b/TGit/OptionsGeneral.cs @@ -36,5 +36,10 @@ public string CommitMessage [DisplayName(@"Delete remote branch")] [Description("When finishing a feature delete the remote branch by default")] public bool DeleteRemoteBranch { get; set; } + + [Category("TGit")] + [DisplayName(@"Push changes")] + [Description("When finishing a feature push the changes to the remote by default")] + public bool PushChanges { get; set; } } } diff --git a/TGit/OutputBox.Designer.cs b/TGit/OutputBox.Designer.cs index 3c09569..c1c4ac5 100644 --- a/TGit/OutputBox.Designer.cs +++ b/TGit/OutputBox.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.richTextBox = new System.Windows.Forms.RichTextBox(); this.localBranchCheckBox = new System.Windows.Forms.CheckBox(); this.remoteBranchCheckBox = new System.Windows.Forms.CheckBox(); + this.pushCheckBox = new System.Windows.Forms.CheckBox(); this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // @@ -56,7 +57,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.flowLayoutPanel1.Controls.Add(this.okButton); this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(141, 290); + this.flowLayoutPanel1.Location = new System.Drawing.Point(141, 315); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(347, 32); this.flowLayoutPanel1.TabIndex = 4; @@ -78,7 +79,7 @@ private void InitializeComponent() // this.localBranchCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.localBranchCheckBox.AutoSize = true; - this.localBranchCheckBox.Location = new System.Drawing.Point(12, 281); + this.localBranchCheckBox.Location = new System.Drawing.Point(12, 306); this.localBranchCheckBox.Name = "localBranchCheckBox"; this.localBranchCheckBox.Size = new System.Drawing.Size(118, 17); this.localBranchCheckBox.TabIndex = 5; @@ -89,18 +90,29 @@ private void InitializeComponent() // this.remoteBranchCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.remoteBranchCheckBox.AutoSize = true; - this.remoteBranchCheckBox.Location = new System.Drawing.Point(12, 305); + this.remoteBranchCheckBox.Location = new System.Drawing.Point(12, 330); this.remoteBranchCheckBox.Name = "remoteBranchCheckBox"; this.remoteBranchCheckBox.Size = new System.Drawing.Size(128, 17); this.remoteBranchCheckBox.TabIndex = 6; this.remoteBranchCheckBox.Text = "Delete remote branch"; this.remoteBranchCheckBox.UseVisualStyleBackColor = true; // + // pushCheckBox + // + this.pushCheckBox.AutoSize = true; + this.pushCheckBox.Location = new System.Drawing.Point(12, 283); + this.pushCheckBox.Name = "pushCheckBox"; + this.pushCheckBox.Size = new System.Drawing.Size(94, 17); + this.pushCheckBox.TabIndex = 7; + this.pushCheckBox.Text = "Push changes"; + this.pushCheckBox.UseVisualStyleBackColor = true; + // // OutputBox // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(500, 334); + this.ClientSize = new System.Drawing.Size(500, 359); + this.Controls.Add(this.pushCheckBox); this.Controls.Add(this.remoteBranchCheckBox); this.Controls.Add(this.localBranchCheckBox); this.Controls.Add(this.flowLayoutPanel1); @@ -123,5 +135,6 @@ private void InitializeComponent() public System.Windows.Forms.RichTextBox richTextBox; private System.Windows.Forms.CheckBox localBranchCheckBox; private System.Windows.Forms.CheckBox remoteBranchCheckBox; + private System.Windows.Forms.CheckBox pushCheckBox; } } \ No newline at end of file diff --git a/TGit/OutputBox.cs b/TGit/OutputBox.cs index 637c09d..8f8b220 100644 --- a/TGit/OutputBox.cs +++ b/TGit/OutputBox.cs @@ -10,11 +10,14 @@ namespace SamirBoulema.TGit public sealed partial class OutputBox : Form { private readonly string _branchName; + private readonly string _pushCommand; - public OutputBox(string branchName, OptionPageGrid options) + public OutputBox(string branchName, OptionPageGrid options, string pushCommand) { InitializeComponent(); + _branchName = branchName; + _pushCommand = pushCommand; richTextBox.TextChanged += textBox_TextChanged; @@ -22,6 +25,8 @@ public OutputBox(string branchName, OptionPageGrid options) { localBranchCheckBox.Visible = false; remoteBranchCheckBox.Visible = false; + pushCheckBox.Visible = false; + richTextBox.Height += 30; } else { @@ -32,20 +37,23 @@ public OutputBox(string branchName, OptionPageGrid options) { localBranchCheckBox.Checked = options.DeleteLocalBranch; remoteBranchCheckBox.Checked = options.DeleteRemoteBranch; + pushCheckBox.Checked = options.PushChanges; } } private void okButton_Click(object sender, EventArgs e) { - if (localBranchCheckBox.Checked || remoteBranchCheckBox.Checked) + if (localBranchCheckBox.Checked || remoteBranchCheckBox.Checked || pushCheckBox.Checked) { var process = ProcessHelper.StartProcessGui( "cmd.exe", $"/c cd \"{EnvHelper.SolutionDir}\" && " + GitHelper.GetSshSetup() + + "echo. && " + + (pushCheckBox.Checked ? _pushCommand : "echo.") + FormatCliCommand($"branch -d {_branchName}") + (remoteBranchCheckBox.Checked ? FormatCliCommand($"push origin --delete {_branchName}", false) : "echo."), - "Deleting branches...", string.Empty, this + "Finishing...", string.Empty, this ); process.WaitForExit(); okButton.Click += OkButton_Click_Close; diff --git a/TGit/source.extension.vsixmanifest b/TGit/source.extension.vsixmanifest index 70da745..6dd325d 100644 --- a/TGit/source.extension.vsixmanifest +++ b/TGit/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + TGit Control TortoiseGit from within Visual Studio https://github.com/sboulema/TGit