Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public void ShouldNotAllowIncrementOfVersion()
[TestCase("Merge branch 'Release-v0.2.0'", true, "0.2.0")]
[TestCase("Merge branch 'Release-v2.2'", true, "2.2.0")]
[TestCase("Merge remote-tracking branch 'origin/release/0.8.0' into develop/master", true, "0.8.0")]
[TestCase("Merge release/5.1.0 to master", true, "5.1.0")] // Team Foundation Server 2017 default merge message (en-US)
[TestCase("Zusammengeführter PR \"9\": release/5.1.0 mit master mergen", true, "5.1.0")] // Team Foundation Server 2017 default merge message (de-DE)
[TestCase("Merge remote-tracking branch 'refs/remotes/origin/release/2.0.0'", true, "2.0.0")]
public void TakesVersionFromMergeOfReleaseBranch(string message, bool isMergeCommit, string expectedVersion)
{
Expand Down
26 changes: 25 additions & 1 deletion src/GitVersionCore/MergeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class MergeMessage
static Regex parseRemoteTrackingMergeMessage = new Regex(
@"^Merge remote-tracking branch '(?<SourceBranch>.*)'( into (?<TargetBranch>.*))?",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
static Regex parseTfsMergeMessageEnglishUS = new Regex(
@"^Merge (?<SourceBranch>.*) to (?<TargetBranch>.*)",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
// Zusammengeführter PR \"9\": release/5.0.1 mit master mergen
static Regex parseTfsMergeMessageGermanDE = new Regex(
@"^Zusammengeführter PR ""(?<PullRequestNumber>\d*)""\: (?<SourceBranch>.*) mit (?<TargetBranch>.*) mergen",
RegexOptions.IgnoreCase | RegexOptions.Compiled);

private string mergeMessage;

Expand Down Expand Up @@ -86,12 +93,29 @@ private string ParseBranch()
}

match = parseRemoteTrackingMergeMessage.Match(mergeMessage);
if (match.Success) {
if (match.Success)
{
var from = match.Groups["SourceBranch"].Value;
// TODO We could remove/separate the remote name at this point?
return from;
}

match = parseTfsMergeMessageEnglishUS.Match(mergeMessage);
if (match.Success)
{
IsMergedPullRequest = true;
var from = match.Groups["SourceBranch"].Value;
return from;
}

match = parseTfsMergeMessageGermanDE.Match(mergeMessage);
if (match.Success)
{
IsMergedPullRequest = true;
var from = match.Groups["SourceBranch"].Value;
return from;
}

return "";
}

Expand Down