Skip to content

Commit 8a8a2a8

Browse files
authored
Merge pull request #3953 from HHobeck/feature/consider-ignore-property
Consider somehow the IGitVersionConfiguration::Ignore property
2 parents 58d8bda + 74adfe4 commit 8a8a2a8

27 files changed

+623
-118
lines changed

BREAKING_CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
* TrunkBased
5656
* The initialization wizard has been removed.
5757
* On the `develop`, `release` and `hotfix` branch the introduced branch related property `prevent-increment.when-current-commit-tagged` has been set to `false` to get the incremented instead of the tagged semantic version.
58+
* When setting the "ignore commits before" parameter to a future value, an exception will occur if no commits are found on the current branch. This behavior mimics that of an empty repository.
5859
5960
## v5.0.0
6061

docs/input/docs/reference/configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ branches:
384384
regex: (?<BranchName>.+)
385385
source-branches:
386386
- main
387-
- release
388387
- feature
388+
- hotfix
389389
- pull-request
390390
ignore:
391391
sha: []

src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ branches:
5959
regex: (?<BranchName>.+)
6060
source-branches:
6161
- main
62-
- release
6362
- feature
63+
- hotfix
6464
- pull-request
6565
ignore:
6666
sha: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using GitVersion.VersionCalculation;
2+
3+
namespace GitVersion.Configuration;
4+
5+
internal sealed class TrunkBasedConfigurationBuilder : ConfigurationBuilderBase<TrunkBasedConfigurationBuilder>
6+
{
7+
public static TrunkBasedConfigurationBuilder New => new();
8+
9+
private TrunkBasedConfigurationBuilder()
10+
{
11+
WithConfiguration(new GitVersionConfiguration()
12+
{
13+
AssemblyFileVersioningScheme = ConfigurationConstants.DefaultAssemblyFileVersioningScheme,
14+
AssemblyVersioningScheme = ConfigurationConstants.DefaultAssemblyVersioningScheme,
15+
CommitDateFormat = ConfigurationConstants.DefaultCommitDateFormat,
16+
MajorVersionBumpMessage = IncrementStrategyFinder.DefaultMajorPattern,
17+
MinorVersionBumpMessage = IncrementStrategyFinder.DefaultMinorPattern,
18+
NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern,
19+
PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern,
20+
SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat,
21+
VersionStrategies = [
22+
VersionStrategies.ConfiguredNextVersion,
23+
VersionStrategies.TrunkBased
24+
],
25+
TagPrefix = ConfigurationConstants.DefaultTagPrefix,
26+
VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
27+
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
28+
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
29+
DeploymentMode = DeploymentMode.ManualDeployment,
30+
RegularExpression = string.Empty,
31+
Label = ConfigurationConstants.BranchNamePlaceholder,
32+
Increment = IncrementStrategy.Inherit,
33+
CommitMessageIncrementing = CommitMessageIncrementMode.Enabled,
34+
PreventIncrement = new PreventIncrementConfiguration()
35+
{
36+
OfMergedBranch = false,
37+
WhenBranchMerged = false,
38+
WhenCurrentCommitTagged = true
39+
},
40+
TrackMergeTarget = false,
41+
TrackMergeMessage = true,
42+
TracksReleaseBranches = false,
43+
IsReleaseBranch = false,
44+
IsMainBranch = false
45+
});
46+
47+
WithBranch(MainBranch.Name).WithConfiguration(new BranchConfiguration()
48+
{
49+
Increment = IncrementStrategy.Patch,
50+
RegularExpression = MainBranch.RegexPattern,
51+
DeploymentMode = DeploymentMode.ContinuousDeployment,
52+
SourceBranches = [],
53+
Label = string.Empty,
54+
PreventIncrement = new PreventIncrementConfiguration()
55+
{
56+
OfMergedBranch = true
57+
},
58+
TrackMergeTarget = false,
59+
TracksReleaseBranches = false,
60+
IsMainBranch = true,
61+
IsReleaseBranch = false,
62+
PreReleaseWeight = 55000
63+
});
64+
65+
WithBranch(FeatureBranch.Name).WithConfiguration(new BranchConfiguration()
66+
{
67+
Increment = IncrementStrategy.Minor,
68+
RegularExpression = FeatureBranch.RegexPattern,
69+
SourceBranches =
70+
[
71+
this.MainBranch.Name
72+
],
73+
PreventIncrement = new PreventIncrementConfiguration()
74+
{
75+
WhenCurrentCommitTagged = false
76+
},
77+
PreReleaseWeight = 30000
78+
});
79+
80+
WithBranch(HotfixBranch.Name).WithConfiguration(new BranchConfiguration()
81+
{
82+
Increment = IncrementStrategy.Patch,
83+
RegularExpression = HotfixBranch.RegexPattern,
84+
SourceBranches =
85+
[
86+
this.MainBranch.Name
87+
],
88+
PreventIncrement = new PreventIncrementConfiguration()
89+
{
90+
WhenCurrentCommitTagged = false
91+
},
92+
PreReleaseWeight = 30000
93+
});
94+
95+
WithBranch(PullRequestBranch.Name).WithConfiguration(new BranchConfiguration
96+
{
97+
Increment = IncrementStrategy.Inherit,
98+
RegularExpression = PullRequestBranch.RegexPattern,
99+
DeploymentMode = DeploymentMode.ManualDeployment,
100+
SourceBranches =
101+
[
102+
this.MainBranch.Name
103+
],
104+
Label = "PullRequest",
105+
LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern,
106+
PreReleaseWeight = 30000
107+
});
108+
109+
WithBranch(UnknownBranch.Name).WithConfiguration(new BranchConfiguration
110+
{
111+
RegularExpression = UnknownBranch.RegexPattern,
112+
DeploymentMode = DeploymentMode.ManualDeployment,
113+
Increment = IncrementStrategy.Inherit,
114+
SourceBranches =
115+
[
116+
this.MainBranch.Name,
117+
this.FeatureBranch.Name,
118+
this.PullRequestBranch.Name
119+
]
120+
});
121+
}
122+
}

src/GitVersion.Core.Tests/IntegrationTests/IgnoreBeforeScenarios.cs

-40
This file was deleted.

0 commit comments

Comments
 (0)