Skip to content

Commit

Permalink
Add support for GitFlow version tag #30
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Jun 1, 2017
1 parent 62ab84b commit 1ff07a0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
7 changes: 5 additions & 2 deletions TGit/Commands/GitFlowMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
34 changes: 29 additions & 5 deletions TGit/FlowDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion TGit/FlowDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
10 changes: 7 additions & 3 deletions TGit/FlowOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Windows.Forms;
using System.Linq;

namespace SamirBoulema.TGit
{
Expand All @@ -11,6 +9,7 @@ public class FlowOptions
public string FeaturePrefix;
public string ReleasePrefix;
public string HotfixPrefix;
public string TagPrefix;

public FlowOptions()
{
Expand All @@ -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(';'))
{
Expand All @@ -47,6 +47,10 @@ public FlowOptions(string input)
{
HotfixPrefix = line.Split(' ').Last();
}
else if (line.StartsWith("gitflow.prefix.versiontag"))
{
TagPrefix = line.Split(' ').Last();
}
}
}
}
Expand Down

0 comments on commit 1ff07a0

Please sign in to comment.