Skip to content

Commit e18d34d

Browse files
committed
Remove TestConfigurationBuilder and crate GitFlow and GitHubFlowConfigurationBuilder. Rename SratchConfigurationBuilder to EmptyConfgiruationBuilder.
1 parent bb4887f commit e18d34d

14 files changed

+435
-162
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace GitVersion.Core.Tests.Helpers;
2+
3+
internal sealed class EmptyConfigurationBuilder : TestConfigurationBuilderBase<EmptyConfigurationBuilder>
4+
{
5+
public static EmptyConfigurationBuilder New => new();
6+
7+
private EmptyConfigurationBuilder()
8+
{
9+
}
10+
}
Lines changed: 180 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using GitVersion.Configuration;
1+
using GitVersion.Extensions;
2+
using GitVersion.VersionCalculation;
23

34
namespace GitVersion.Core.Tests.Helpers;
45

@@ -8,8 +9,183 @@ internal sealed class GitFlowConfigurationBuilder : TestConfigurationBuilderBase
89

910
private GitFlowConfigurationBuilder()
1011
{
11-
ConfigurationBuilder configurationBuilder = new();
12-
var configuration = configurationBuilder.Build();
13-
WithConfiguration(configuration);
12+
WithConfiguration(new()
13+
{
14+
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
15+
AssemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch,
16+
TagPrefix = "[vV]",
17+
VersioningMode = VersioningMode.ContinuousDelivery,
18+
ContinuousDeploymentFallbackTag = "ci",
19+
MajorVersionBumpMessage = IncrementStrategyFinder.DefaultMajorPattern,
20+
MinorVersionBumpMessage = IncrementStrategyFinder.DefaultMinorPattern,
21+
PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern,
22+
NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern,
23+
CommitMessageIncrementing = CommitMessageIncrementMode.Enabled,
24+
CommitDateFormat = "yyyy-MM-dd",
25+
UpdateBuildNumber = true,
26+
SemanticVersionFormat = SemanticVersionFormat.Strict,
27+
TagPreReleaseWeight = 60000,
28+
Increment = IncrementStrategy.Inherit
29+
});
30+
31+
WithBranch(DevelopBranch.Name).WithConfiguration(new()
32+
{
33+
VersioningMode = VersioningMode.ContinuousDeployment,
34+
Increment = IncrementStrategy.Minor,
35+
Regex = DevelopBranch.RegexPattern,
36+
SourceBranches = new HashSet<string>(),
37+
Tag = "alpha",
38+
PreventIncrementOfMergedBranchVersion = false,
39+
TrackMergeTarget = true,
40+
TracksReleaseBranches = true,
41+
IsMainline = false,
42+
IsReleaseBranch = false,
43+
PreReleaseWeight = 0
44+
});
45+
46+
WithBranch(MainBranch.Name).WithConfiguration(new()
47+
{
48+
VersioningMode = VersioningMode.ContinuousDelivery,
49+
Increment = IncrementStrategy.Patch,
50+
Regex = MainBranch.RegexPattern,
51+
SourceBranches = new HashSet<string> {
52+
DevelopBranch.Name,
53+
ReleaseBranch.Name
54+
},
55+
Tag = string.Empty,
56+
PreventIncrementOfMergedBranchVersion = true,
57+
TrackMergeTarget = false,
58+
TracksReleaseBranches = false,
59+
IsMainline = true,
60+
IsReleaseBranch = false,
61+
PreReleaseWeight = 55000
62+
});
63+
64+
WithBranch(ReleaseBranch.Name).WithConfiguration(new()
65+
{
66+
VersioningMode = VersioningMode.ContinuousDelivery,
67+
Increment = IncrementStrategy.None,
68+
Regex = ReleaseBranch.RegexPattern,
69+
SourceBranches = new HashSet<string> {
70+
DevelopBranch.Name,
71+
MainBranch.Name,
72+
SupportBranch.Name,
73+
ReleaseBranch.Name
74+
},
75+
Tag = "beta",
76+
PreventIncrementOfMergedBranchVersion = true,
77+
TrackMergeTarget = false,
78+
TracksReleaseBranches = false,
79+
IsMainline = false,
80+
IsReleaseBranch = true,
81+
PreReleaseWeight = 30000
82+
});
83+
84+
WithBranch(FeatureBranch.Name).WithConfiguration(new()
85+
{
86+
VersioningMode = VersioningMode.ContinuousDelivery,
87+
Increment = IncrementStrategy.Inherit,
88+
Regex = FeatureBranch.RegexPattern,
89+
SourceBranches = new HashSet<string> {
90+
DevelopBranch.Name,
91+
MainBranch.Name,
92+
ReleaseBranch.Name,
93+
FeatureBranch.Name,
94+
SupportBranch.Name,
95+
HotfixBranch.Name
96+
},
97+
Tag = "{BranchName}",
98+
PreReleaseWeight = 30000
99+
});
100+
101+
WithBranch(PullRequestBranch.Name).WithConfiguration(new()
102+
{
103+
VersioningMode = VersioningMode.ContinuousDelivery,
104+
Increment = IncrementStrategy.Inherit,
105+
Regex = PullRequestBranch.RegexPattern,
106+
SourceBranches = new HashSet<string> {
107+
DevelopBranch.Name,
108+
MainBranch.Name,
109+
ReleaseBranch.Name,
110+
FeatureBranch.Name,
111+
SupportBranch.Name,
112+
HotfixBranch.Name
113+
},
114+
Tag = "PullRequest",
115+
TagNumberPattern = @"[/-](?<number>\d+)",
116+
PreReleaseWeight = 30000
117+
});
118+
119+
WithBranch(HotfixBranch.Name).WithConfiguration(new()
120+
{
121+
VersioningMode = VersioningMode.ContinuousDelivery,
122+
Increment = IncrementStrategy.Inherit,
123+
Regex = HotfixBranch.RegexPattern,
124+
SourceBranches = new HashSet<string> {
125+
ReleaseBranch.Name,
126+
MainBranch.Name,
127+
SupportBranch.Name,
128+
HotfixBranch.Name
129+
},
130+
Tag = "beta",
131+
PreReleaseWeight = 30000
132+
});
133+
134+
WithBranch(SupportBranch.Name).WithConfiguration(new()
135+
{
136+
VersioningMode = VersioningMode.ContinuousDelivery,
137+
Increment = IncrementStrategy.Patch,
138+
Regex = SupportBranch.RegexPattern,
139+
SourceBranches = new HashSet<string> { MainBranch.Name },
140+
Tag = string.Empty,
141+
PreventIncrementOfMergedBranchVersion = true,
142+
TrackMergeTarget = false,
143+
TracksReleaseBranches = false,
144+
IsMainline = true,
145+
IsReleaseBranch = false,
146+
PreReleaseWeight = 55000
147+
});
14148
}
149+
150+
public static BranchMetaData MainBranch = new()
151+
{
152+
Name = "main",
153+
RegexPattern = "^master$|^main$"
154+
};
155+
156+
public static BranchMetaData DevelopBranch = new()
157+
{
158+
Name = "develop",
159+
RegexPattern = "^dev(elop)?(ment)?$"
160+
};
161+
162+
public static BranchMetaData ReleaseBranch = new()
163+
{
164+
Name = "release",
165+
RegexPattern = "^releases?[/-]"
166+
};
167+
168+
public static BranchMetaData FeatureBranch = new()
169+
{
170+
Name = "feature",
171+
RegexPattern = "^features?[/-]"
172+
};
173+
174+
public static BranchMetaData PullRequestBranch = new()
175+
{
176+
Name = "pull-request",
177+
RegexPattern = @"^(pull|pull\-requests|pr)[/-]"
178+
};
179+
180+
public static BranchMetaData HotfixBranch = new()
181+
{
182+
Name = "hotfix",
183+
RegexPattern = "^hotfix(es)?[/-]"
184+
};
185+
186+
public static BranchMetaData SupportBranch = new()
187+
{
188+
Name = "support",
189+
RegexPattern = "^support[/-]"
190+
};
15191
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
using GitVersion.Extensions;
2+
using GitVersion.VersionCalculation;
3+
4+
namespace GitVersion.Core.Tests.Helpers;
5+
6+
internal sealed class GitHubFlowConfigurationBuilder : TestConfigurationBuilderBase<GitHubFlowConfigurationBuilder>
7+
{
8+
public static GitHubFlowConfigurationBuilder New => new();
9+
10+
private GitHubFlowConfigurationBuilder()
11+
{
12+
WithConfiguration(new()
13+
{
14+
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
15+
AssemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch,
16+
TagPrefix = "[vV]",
17+
VersioningMode = VersioningMode.ContinuousDelivery,
18+
ContinuousDeploymentFallbackTag = "ci",
19+
MajorVersionBumpMessage = IncrementStrategyFinder.DefaultMajorPattern,
20+
MinorVersionBumpMessage = IncrementStrategyFinder.DefaultMinorPattern,
21+
PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern,
22+
NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern,
23+
CommitMessageIncrementing = CommitMessageIncrementMode.Enabled,
24+
CommitDateFormat = "yyyy-MM-dd",
25+
UpdateBuildNumber = true,
26+
SemanticVersionFormat = SemanticVersionFormat.Strict,
27+
TagPreReleaseWeight = 60000,
28+
Increment = IncrementStrategy.Inherit
29+
});
30+
31+
WithBranch(MainBranch.Name).WithConfiguration(new()
32+
{
33+
VersioningMode = VersioningMode.ContinuousDelivery,
34+
Increment = IncrementStrategy.Patch,
35+
Regex = MainBranch.RegexPattern,
36+
SourceBranches = new HashSet<string> {
37+
ReleaseBranch.Name
38+
},
39+
Tag = string.Empty,
40+
PreventIncrementOfMergedBranchVersion = true,
41+
TrackMergeTarget = false,
42+
TracksReleaseBranches = false,
43+
IsMainline = true,
44+
IsReleaseBranch = false,
45+
PreReleaseWeight = 55000
46+
});
47+
48+
WithBranch(ReleaseBranch.Name).WithConfiguration(new()
49+
{
50+
VersioningMode = VersioningMode.ContinuousDelivery,
51+
Increment = IncrementStrategy.None,
52+
Regex = ReleaseBranch.RegexPattern,
53+
SourceBranches = new HashSet<string> {
54+
MainBranch.Name,
55+
ReleaseBranch.Name
56+
},
57+
Tag = "beta",
58+
PreventIncrementOfMergedBranchVersion = true,
59+
TrackMergeTarget = false,
60+
TracksReleaseBranches = false,
61+
IsMainline = false,
62+
IsReleaseBranch = true,
63+
PreReleaseWeight = 30000
64+
});
65+
66+
WithBranch(FeatureBranch.Name).WithConfiguration(new()
67+
{
68+
VersioningMode = VersioningMode.ContinuousDelivery,
69+
Increment = IncrementStrategy.Inherit,
70+
Regex = FeatureBranch.RegexPattern,
71+
SourceBranches = new HashSet<string> {
72+
MainBranch.Name,
73+
ReleaseBranch.Name,
74+
FeatureBranch.Name
75+
},
76+
Tag = "{BranchName}",
77+
PreReleaseWeight = 30000
78+
});
79+
80+
WithBranch(PullRequestBranch.Name).WithConfiguration(new()
81+
{
82+
VersioningMode = VersioningMode.ContinuousDelivery,
83+
Increment = IncrementStrategy.Inherit,
84+
Regex = PullRequestBranch.RegexPattern,
85+
SourceBranches = new HashSet<string> {
86+
MainBranch.Name,
87+
ReleaseBranch.Name,
88+
FeatureBranch.Name
89+
},
90+
Tag = "PullRequest",
91+
TagNumberPattern = @"[/-](?<number>\d+)",
92+
PreReleaseWeight = 30000
93+
});
94+
}
95+
96+
public static BranchMetaData MainBranch = new()
97+
{
98+
Name = "main",
99+
RegexPattern = "^master$|^main$"
100+
};
101+
102+
public static BranchMetaData ReleaseBranch = new()
103+
{
104+
Name = "release",
105+
RegexPattern = "^releases?[/-]"
106+
};
107+
108+
public static BranchMetaData FeatureBranch = new()
109+
{
110+
Name = "feature",
111+
RegexPattern = "^features?[/-]"
112+
};
113+
114+
public static BranchMetaData PullRequestBranch = new()
115+
{
116+
Name = "pull-request",
117+
RegexPattern = @"^(pull|pull\-requests|pr)[/-]"
118+
};
119+
}

src/GitVersion.Core.Tests/Helpers/ScratchConfigurationBuilder.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)