Skip to content

Do not pick up version in merge target #750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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 @@ -45,6 +45,7 @@ public void ShouldNotAllowIncrementOfVersion()
[TestCase("Merge branch 'Hotfix/10.10.50'", true, "10.10.50")]
[TestCase("Merge branch 'hotfix-0.1.5'", true, "0.1.5")]
[TestCase("Merge branch 'hotfix-4.2.2' into support-4.2", true, "4.2.2")]
[TestCase("Merge branch 'somebranch' into release-3.0.0", true, null)]
[TestCase("Merge branch 'hotfix-0.1.5'\n\nRelates to: TicketId", true, "0.1.5")]
[TestCase("Merge branch 'alpha-0.1.5'", true, "0.1.5")]
[TestCase("Merge pull request #165 from Particular/release-1.0.0", true, "1.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace GitVersion.VersionCalculation.BaseVersionCalculators
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -41,8 +42,13 @@ private static SemanticVersion Inner(Commit mergeCommit, EffectiveConfiguration
return null;
}

var commitMessage = mergeCommit.Message;
var lastIndexOf = commitMessage.LastIndexOf("into", StringComparison.OrdinalIgnoreCase);
if (lastIndexOf != -1)
commitMessage = commitMessage.Substring(0, lastIndexOf);

//TODO: Make the version prefixes customizable
var possibleVersions = Regex.Matches(mergeCommit.Message, @"^.*?(([rR]elease|[hH]otfix|[aA]lpha)-|-v|/|/v|'|Finish )(?<PossibleVersions>(?<!://)\d+\.\d+(\.*\d+)*)")
var possibleVersions = Regex.Matches(commitMessage, @"^.*?(([rR]elease|[hH]otfix|[aA]lpha)-|-v|/|/v|'|Finish )(?<PossibleVersions>(?<!://)\d+\.\d+(\.*\d+)*)")
.Cast<Match>()
.Select(m => m.Groups["PossibleVersions"].Value);

Expand Down