From 1ff07a0263fb3d4d1aef3851e2742c6cd0f67483 Mon Sep 17 00:00:00 2001 From: "Samir L. Boulema" Date: Thu, 1 Jun 2017 17:09:59 +0200 Subject: [PATCH] Add support for GitFlow version tag #30 --- TGit/Commands/GitFlowMenuCommands.cs | 7 ++++-- TGit/FlowDialog.Designer.cs | 34 ++++++++++++++++++++++++---- TGit/FlowDialog.cs | 3 ++- TGit/FlowOptions.cs | 10 +++++--- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/TGit/Commands/GitFlowMenuCommands.cs b/TGit/Commands/GitFlowMenuCommands.cs index c89671e..fa30b6b 100644 --- a/TGit/Commands/GitFlowMenuCommands.cs +++ b/TGit/Commands/GitFlowMenuCommands.cs @@ -68,6 +68,8 @@ private void InitCommand(object sender, EventArgs e) var flowDialog = new FlowDialog(); if (flowDialog.ShowDialog() != DialogResult.OK) return; + var versionTag = string.IsNullOrEmpty(flowDialog.FlowOptions.TagPrefix) ? "\"\"" : flowDialog.FlowOptions.TagPrefix; + /* 1. Add GitFlow config options * 2. Checkout develop branch (create if it doesn't exist, reset if it does) * 3. Push develop branch @@ -81,6 +83,7 @@ private void InitCommand(object sender, EventArgs e) FormatCliCommand($"config --add gitflow.prefix.feature {flowDialog.FlowOptions.FeaturePrefix}") + FormatCliCommand($"config --add gitflow.prefix.release {flowDialog.FlowOptions.ReleasePrefix}") + FormatCliCommand($"config --add gitflow.prefix.hotfix {flowDialog.FlowOptions.HotfixPrefix}") + + FormatCliCommand($"config --add gitflow.prefix.versiontag {versionTag}") + (GitHelper.RemoteBranchExists(flowDialog.FlowOptions.DevelopBranch) ? "echo." : FormatCliCommand($"checkout -b {flowDialog.FlowOptions.DevelopBranch}", false)), @@ -241,7 +244,7 @@ private void FinishReleaseCommand(object sender, EventArgs e) FormatCliCommand($"checkout {EnvHelper.FlowOptions.MasterBranch}") + FormatCliCommand("pull") + FormatCliCommand($"merge --no-ff {releaseBranch}") + - FormatCliCommand($"tag {releaseName}") + + FormatCliCommand($"tag {EnvHelper.FlowOptions.TagPrefix}{releaseName}") + FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand("pull") + FormatCliCommand($"merge --no-ff {releaseBranch}", false), @@ -303,7 +306,7 @@ private void FinishHotfixCommand(object sender, EventArgs e) FormatCliCommand($"checkout {EnvHelper.FlowOptions.MasterBranch}") + FormatCliCommand("pull") + FormatCliCommand($"merge --no-ff {hotfixBranch}") + - FormatCliCommand($"tag {hotfixName}") + + FormatCliCommand($"tag {EnvHelper.FlowOptions.TagPrefix}{hotfixName}") + FormatCliCommand($"checkout {EnvHelper.FlowOptions.DevelopBranch}") + FormatCliCommand("pull") + FormatCliCommand($"merge --no-ff {hotfixBranch}", false), diff --git a/TGit/FlowDialog.Designer.cs b/TGit/FlowDialog.Designer.cs index ee090cf..03b6e10 100644 --- a/TGit/FlowDialog.Designer.cs +++ b/TGit/FlowDialog.Designer.cs @@ -41,6 +41,8 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.releaseTextBox = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); + this.tagTextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // developTextBox @@ -84,7 +86,7 @@ private void InitializeComponent() // okButton // this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.okButton.Location = new System.Drawing.Point(148, 144); + this.okButton.Location = new System.Drawing.Point(148, 162); this.okButton.Name = "okButton"; this.okButton.Size = new System.Drawing.Size(75, 23); this.okButton.TabIndex = 7; @@ -95,7 +97,7 @@ private void InitializeComponent() // cancelButton // this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancelButton.Location = new System.Drawing.Point(229, 144); + this.cancelButton.Location = new System.Drawing.Point(229, 162); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); this.cancelButton.TabIndex = 8; @@ -160,11 +162,31 @@ private void InitializeComponent() this.label5.TabIndex = 13; this.label5.Text = "Release prefix:"; // - // Flow + // tagTextBox + // + this.tagTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tagTextBox.Location = new System.Drawing.Point(104, 136); + this.tagTextBox.Name = "tagTextBox"; + this.tagTextBox.Size = new System.Drawing.Size(200, 20); + this.tagTextBox.TabIndex = 16; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(12, 139); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(57, 13); + this.label6.TabIndex = 15; + this.label6.Text = "Tag prefix:"; + // + // FlowDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(316, 178); + this.ClientSize = new System.Drawing.Size(316, 194); + this.Controls.Add(this.tagTextBox); + this.Controls.Add(this.label6); this.Controls.Add(this.releaseTextBox); this.Controls.Add(this.label5); this.Controls.Add(this.hotfixTextBox); @@ -178,7 +200,7 @@ private void InitializeComponent() this.Controls.Add(this.developTextBox); this.Controls.Add(this.label1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "Flow"; + this.Name = "FlowDialog"; this.Text = "Flow initialization"; this.ResumeLayout(false); this.PerformLayout(); @@ -199,5 +221,7 @@ private void InitializeComponent() private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox releaseTextBox; private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tagTextBox; + private System.Windows.Forms.Label label6; } } \ No newline at end of file diff --git a/TGit/FlowDialog.cs b/TGit/FlowDialog.cs index 14a918c..13228b9 100644 --- a/TGit/FlowDialog.cs +++ b/TGit/FlowDialog.cs @@ -26,7 +26,8 @@ private void okButton_Click(object sender, EventArgs e) MasterBranch = masterTextBox.Text, FeaturePrefix = featureTextBox.Text, HotfixPrefix = hotfixTextBox.Text, - ReleasePrefix = releaseTextBox.Text + ReleasePrefix = releaseTextBox.Text, + TagPrefix = tagTextBox.Text }; Close(); } diff --git a/TGit/FlowOptions.cs b/TGit/FlowOptions.cs index 3ea2d0d..c137413 100644 --- a/TGit/FlowOptions.cs +++ b/TGit/FlowOptions.cs @@ -1,6 +1,4 @@ -using System; -using System.Linq; -using System.Windows.Forms; +using System.Linq; namespace SamirBoulema.TGit { @@ -11,6 +9,7 @@ public class FlowOptions public string FeaturePrefix; public string ReleasePrefix; public string HotfixPrefix; + public string TagPrefix; public FlowOptions() { @@ -24,6 +23,7 @@ public FlowOptions(string input) FeaturePrefix = string.Empty; ReleasePrefix = string.Empty; HotfixPrefix = string.Empty; + TagPrefix = string.Empty; foreach (var line in input.Split(';')) { @@ -47,6 +47,10 @@ public FlowOptions(string input) { HotfixPrefix = line.Split(' ').Last(); } + else if (line.StartsWith("gitflow.prefix.versiontag")) + { + TagPrefix = line.Split(' ').Last(); + } } } }