Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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 @@ -52,6 +52,7 @@ public void ShouldNotAllowIncrementOfVersion()
[TestCase("Merge branch 'Release-v0.2.0'", true, "0.2.0")]
[TestCase("Merge remote-tracking branch 'origin/release/0.8.0' into develop/" + MainBranch, true, "0.8.0")]
[TestCase("Merge remote-tracking branch 'refs/remotes/origin/release/2.0.0'", true, "2.0.0")]
[TestCase("Merge branch 'Releases/0.2.0'", false, "0.2.0")] // Support Squash Commits
public void TakesVersionFromMergeOfReleaseBranch(string message, bool isMergeCommit, string expectedVersion)
{
var parents = GetParents(isMergeCommit);
Expand All @@ -65,7 +66,7 @@ public void TakesVersionFromMergeOfReleaseBranch(string message, bool isMergeCom
AssertMergeMessage(message + "\n ", expectedVersion, parents);
}

[TestCase("Merge branch 'hotfix-0.1.5'", false)]
// [TestCase("Merge branch 'hotfix-0.1.5'", false)] this is somehow configured as a release branch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please elaborate on how hotfix-0.1.5 is configured as a release branch? Is is-release-branch set to true?

Copy link
Contributor Author

@DSpirit DSpirit Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the is-release-branch is set to true.
Here's an excerpt of the generated configuration:

hotfix:
      mode: ManualDeployment
      label: beta
      increment: Inherit
      prevent-increment:
        when-current-commit-tagged: false
      regex: ^hotfix(es)?[/-](?<BranchName>.+)
      source-branches:
      - release
      - main
      - support
      - hotfix
      is-source-branch-for: []
      is-release-branch: true
      pre-release-weight: 30000

I've changed the failing test to set the hotfix branch as is-release-branch: false, however there might be a different approach that is unknown to me.

[TestCase("Merge branch 'develop' of github.com:Particular/NServiceBus into develop", true)]
[TestCase("Merge branch '4.0.3'", true)]
[TestCase("Merge branch 's'", true)]
Expand Down
9 changes: 3 additions & 6 deletions src/GitVersion.Core/MergeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@ public static bool TryParse(
mergeCommit.NotNull();
configuration.NotNull();

mergeMessage = null;
mergeMessage = new(mergeCommit.Message, configuration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mergeMessage should not be set if the return value equals false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I've changed it.


if (mergeCommit.IsMergeCommit)
{
mergeMessage = new(mergeCommit.Message, configuration);
}
var isReleaseBranch = mergeMessage.MergedBranch != null && configuration.IsReleaseBranch(mergeMessage.MergedBranch);

return mergeMessage != null;
return mergeCommit.IsMergeCommit || isReleaseBranch;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ private static bool TryParse(ICommit mergeCommit, GitVersionContext context, [No
return mergeMessage != null;
}

private static MergeMessage? Inner(ICommit mergeCommit, GitVersionContext context)
{
if (mergeCommit.Parents.Count() < 2)
{
return null;
}

var mergeMessage = new MergeMessage(mergeCommit.Message, context.Configuration);
return mergeMessage;
}
private static MergeMessage? Inner(ICommit mergeCommit, GitVersionContext context) =>
MergeMessage.TryParse(mergeCommit, context.Configuration, out MergeMessage? mergeMessage)
? mergeMessage
: null;
}