Skip to content

Commit

Permalink
Integrate code review remarks from arturcic
Browse files Browse the repository at this point in the history
  • Loading branch information
HHobeck committed Mar 15, 2024
1 parent fe27454 commit b4882b6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 41 deletions.
9 changes: 4 additions & 5 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
regex: ^releases?[/-](?<BranchName>.+)
source-branches:
- develop
- main
Expand Down Expand Up @@ -153,7 +153,7 @@ branches:
increment: Inherit
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-]
regex: ^hotfix(es)?[/-](?<BranchName>.+)
source-branches:
- release
- main
Expand All @@ -168,7 +168,7 @@ branches:
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-]
regex: ^support[/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand Down Expand Up @@ -209,7 +209,6 @@ is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
```

The supported built-in configuration for the `GitHubFlow` workflow (`workflow: GitHubFlow/v1`) looks like:
Expand Down Expand Up @@ -257,7 +256,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
regex: ^releases?[/-](?<BranchName>.+)
source-branches:
- main
- release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
regex: ^releases?[/-](?<BranchName>.+)
source-branches:
- develop
- main
Expand Down Expand Up @@ -102,7 +102,7 @@ branches:
increment: Inherit
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-]
regex: ^hotfix(es)?[/-](?<BranchName>.+)
source-branches:
- release
- main
Expand All @@ -117,7 +117,7 @@ branches:
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-]
regex: ^support[/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
regex: ^releases?[/-](?<BranchName>.+)
source-branches:
- develop
- main
Expand Down Expand Up @@ -102,7 +102,7 @@ branches:
increment: Inherit
prevent-increment:
when-current-commit-tagged: false
regex: ^hotfix(es)?[/-]
regex: ^hotfix(es)?[/-](?<BranchName>.+)
source-branches:
- release
- main
Expand All @@ -117,7 +117,7 @@ branches:
prevent-increment:
of-merged-branch: true
track-merge-target: false
regex: ^support[/-]
regex: ^support[/-](?<BranchName>.+)
source-branches:
- main
is-source-branch-for: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ branches:
of-merged-branch: true
when-current-commit-tagged: false
track-merge-target: false
regex: ^releases?[/-]
regex: ^releases?[/-](?<BranchName>.+)
source-branches:
- main
- release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private TrunkBasedConfigurationBuilder()
WithBranch(HotfixBranch.Name).WithConfiguration(new BranchConfiguration()
{
Increment = IncrementStrategy.Patch,
RegularExpression = "^hotfix(es)?[/-](?<BranchName>.+)",
RegularExpression = HotfixBranch.RegexPattern,
SourceBranches =
[
this.MainBranch.Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ private static GitFlowConfigurationBuilder GetConfigurationBuilder() => GitFlowC
.WithSourceBranches("main")
);

[Test]
[Ignore("Support of multiple tunks are not implemented at the moment.")]
public void VerifyNonMainMainlineVersionIdenticalAsMain()
{
var configuration = GetConfigurationBuilder().Build();

using var fixture = new EmptyRepositoryFixture();
fixture.Repository.MakeACommit("1");

fixture.BranchTo("feature/foo", "foo");
fixture.MakeACommit("2 +semver: major");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("feature/foo");

fixture.AssertFullSemver("1.0.0", configuration);

fixture.BranchTo("support/1.0", "support");

fixture.AssertFullSemver("1.0.0", configuration);
}

[Test]
public void MergedFeatureBranchesToMainImpliesRelease()
{
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersion.Core/Configuration/ConfigurationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ internal static class ConfigurationConstants

public const string MainBranchRegex = "^master$|^main$";
public const string DevelopBranchRegex = "^dev(elop)?(ment)?$";
public const string ReleaseBranchRegex = "^releases?[/-]";
public const string ReleaseBranchRegex = "^releases?[/-](?<BranchName>.+)";
public const string FeatureBranchRegex = "^features?[/-](?<BranchName>.+)";
public const string PullRequestBranchRegex = @"^(pull|pull\-requests|pr)[/-]";
public const string HotfixBranchRegex = "^hotfix(es)?[/-]";
public const string SupportBranchRegex = "^support[/-]";
public const string HotfixBranchRegex = "^hotfix(es)?[/-](?<BranchName>.+)";
public const string SupportBranchRegex = "^support[/-](?<BranchName>.+)";
public const string UnknownBranchRegex = "(?<BranchName>.+)";
}
8 changes: 4 additions & 4 deletions src/GitVersion.Core/MergeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ namespace GitVersion;

public class MergeMessage
{
private static readonly IList<MergeMessageFormat> DefaultFormats = new List<MergeMessageFormat>
{
private static readonly IList<MergeMessageFormat> DefaultFormats = [
new("Default", @"^Merge (branch|tag) '(?<SourceBranch>[^']*)'(?: into (?<TargetBranch>[^\s]*))*"),
new("SmartGit", @"^Finish (?<SourceBranch>[^\s]*)(?: into (?<TargetBranch>[^\s]*))*"),
new("BitBucketPull", @"^Merge pull request #(?<PullRequestNumber>\d+) (from|in) (?<Source>.*) from (?<SourceBranch>[^\s]*) to (?<TargetBranch>[^\s]*)"),
new("BitBucketPullv7", @"^Pull request #(?<PullRequestNumber>\d+).*\r?\n\r?\nMerge in (?<Source>.*) from (?<SourceBranch>[^\s]*) to (?<TargetBranch>[^\s]*)"),
new("BitBucketCloudPull", @"^Merged in (?<SourceBranch>[^\s]*) \(pull request #(?<PullRequestNumber>\d+)\)"),
new("GitHubPull", @"^Merge pull request #(?<PullRequestNumber>\d+) (from|in) (?:[^\s\/]+\/)?(?<SourceBranch>[^\s]*)(?: into (?<TargetBranch>[^\s]*))*"),
new("RemoteTracking", @"^Merge remote-tracking branch '(?<SourceBranch>[^\s]*)'(?: into (?<TargetBranch>[^\s]*))*")
};
new("RemoteTracking", @"^Merge remote-tracking branch '(?<SourceBranch>[^\s]*)'(?: into (?<TargetBranch>[^\s]*))*"),
new("AzureDevOpsPull", @"^Merge pull request (?<PullRequestNumber>\d+) from (?<SourceBranch>[^\s]*) into (?<TargetBranch>[^\s]*)")
];

public MergeMessage(string mergeMessage, IGitVersionConfiguration configuration)
{
Expand Down

0 comments on commit b4882b6

Please sign in to comment.