Skip to content

Commit 4974298

Browse files
Sebastian NemethJakeGinnivan
authored andcommitted
Adding support for Syntevo SmartGit/Hg's GitFlow merge commit message conventions.
1 parent d456fc2 commit 4974298

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

GitVersionCore/MergeMessageParser.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ public static bool TryParse(Commit mergeCommit, out string versionPart)
8080
return false;
8181
}
8282
}
83+
else if (message.StartsWith("Finish Release-")) //Match Syntevo SmartGit client's GitFlow 'release' merge commit message formatting
84+
{
85+
var branch = Regex.Match(message, "Release-(?<branch>.*)").Groups["branch"].Value;
86+
var lastBranchPart = branch.Split('/', '-').Last();
87+
88+
if (!char.IsNumber(lastBranchPart.First()) || !lastBranchPart.Contains("."))
89+
{
90+
return false;
91+
}
92+
93+
versionPart = lastBranchPart;
94+
return true;
95+
}
96+
else if (message.StartsWith("Finish ")) //Match Syntevo SmartGit client's GitFlow 'hotfix' merge commit message formatting
97+
{
98+
var branch = Regex.Match(message, "Finish (?<branch>.*)").Groups["branch"].Value;
99+
var lastBranchPart = branch.Split('/', '-').Last();
100+
101+
if (!char.IsNumber(lastBranchPart.First()) || !lastBranchPart.Contains("."))
102+
{
103+
return false;
104+
}
105+
106+
versionPart = lastBranchPart;
107+
return true;
108+
}
83109
else
84110
{
85111
return false;

Tests/MergeMessageParserTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class MergeMessageParserTests
2222
[TestCase("Merge pull request #95 from Particular/issue-94", false, null)]
2323
[TestCase("Merge pull request #165 in Particular/release-1.0.0", true, "1.0.0")]
2424
[TestCase("Merge pull request #95 in Particular/issue-94", false, null)]
25+
[TestCase("Finish Release-0.12.0", true, "0.12.0")] //Support Syntevo SmartGit/Hg's Gitflow merge commit messages for finishing a 'Release' branch
26+
[TestCase("Finish 0.14.1", true, "0.14.1")] //Support Syntevo SmartGit/Hg's Gitflow merge commit messages for finishing a 'Hotfix' branch
2527
public void AssertMergeMessage(string message, bool isMergeCommit, string expectedVersion)
2628
{
2729
var c = new MockCommit

0 commit comments

Comments
 (0)