Skip to content

Commit 3c14826

Browse files
author
Jake Ginnivan
committed
fix(merge messages): Add support for merge remote tracking style merge messages
1 parent 94cf3ab commit 3c14826

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public void ShouldNotAllowIncrementOfVersion()
5858
[TestCase("Finish 0.14.1", true, "0.14.1")] //Support Syntevo SmartGit/Hg's Gitflow merge commit messages for finishing a 'Hotfix' branch
5959
[TestCase("Merge branch 'Release-v0.2.0'", true, "0.2.0")]
6060
[TestCase("Merge branch 'Release-v2.2'", true, "2.2.0")]
61+
[TestCase("Merge remote-tracking branch 'origin/release/0.8.0' into develop/master", true, "0.8.0")]
6162
public void AssertMergeMessage(string message, bool isMergeCommit, string expectedVersion)
6263
{
6364
var parents = GetParents(isMergeCommit);
@@ -121,6 +122,7 @@ static void AssertMergeMessage(string message, string expectedVersion, List<Comm
121122
}
122123
else
123124
{
125+
baseVersion.ShouldNotBeNull();
124126
baseVersion.SemanticVersion.ToString().ShouldBe(expectedVersion);
125127
}
126128
}

src/GitVersionCore/MergeMessage.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class MergeMessage
1515
static Regex smartGitMergeMessage = new Regex(
1616
@"^Finish (?<Branch>.*)",
1717
RegexOptions.IgnoreCase | RegexOptions.Compiled);
18+
static Regex parseRemoteTrackingMergeMessage = new Regex(
19+
@"^Merge remote-tracking branch '(?<SourceBranch>.*)' into (?<TargetBranch>.*)",
20+
RegexOptions.IgnoreCase | RegexOptions.Compiled);
21+
1822
private string mergeMessage;
1923
private Config config;
2024

@@ -73,7 +77,14 @@ private string ParseBranch()
7377
PullRequestNumber = pullNumber;
7478
}
7579
var from = match.Groups["Source"].Value;
76-
// We could remove/separate the remote name at this point?
80+
// TODO We could remove/separate the remote name at this point?
81+
return from;
82+
}
83+
84+
match = parseRemoteTrackingMergeMessage.Match(mergeMessage);
85+
if (match.Success) {
86+
var from = match.Groups["SourceBranch"].Value;
87+
// TODO We could remove/separate the remote name at this point?
7788
return from;
7889
}
7990

0 commit comments

Comments
 (0)