Skip to content

Commit 7aebc27

Browse files
committed
use ConfigurationConstants instead of hardcoded strings
1 parent 4c039e7 commit 7aebc27

File tree

3 files changed

+49
-79
lines changed

3 files changed

+49
-79
lines changed

src/GitVersion.Core/Configuration/ConfigurationBuilderBase.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,54 @@ internal abstract class ConfigurationBuilderBase<TConfigurationBuilder>
4141
private bool? isMainline;
4242
private int? preReleaseWeight;
4343

44+
protected readonly BranchMetaData MainBranch = new()
45+
{
46+
Name = ConfigurationConstants.MainBranchKey,
47+
RegexPattern = ConfigurationConstants.MainBranchRegex
48+
};
49+
50+
protected readonly BranchMetaData DevelopBranch = new()
51+
{
52+
Name = ConfigurationConstants.DevelopBranchKey,
53+
RegexPattern = ConfigurationConstants.DevelopBranchRegex
54+
};
55+
56+
protected readonly BranchMetaData ReleaseBranch = new()
57+
{
58+
Name = ConfigurationConstants.ReleaseBranchKey,
59+
RegexPattern = ConfigurationConstants.ReleaseBranchRegex
60+
};
61+
62+
protected readonly BranchMetaData FeatureBranch = new()
63+
{
64+
Name = ConfigurationConstants.FeatureBranchKey,
65+
RegexPattern = ConfigurationConstants.FeatureBranchRegex
66+
};
67+
68+
protected readonly BranchMetaData PullRequestBranch = new()
69+
{
70+
Name = ConfigurationConstants.PullRequestBranchKey,
71+
RegexPattern = ConfigurationConstants.PullRequestBranchRegex
72+
};
73+
74+
protected readonly BranchMetaData HotfixBranch = new()
75+
{
76+
Name = ConfigurationConstants.HotfixBranchKey,
77+
RegexPattern = ConfigurationConstants.HotfixBranchRegex
78+
};
79+
80+
protected readonly BranchMetaData SupportBranch = new()
81+
{
82+
Name = ConfigurationConstants.SupportBranchKey,
83+
RegexPattern = ConfigurationConstants.SupportBranchRegex
84+
};
85+
86+
protected readonly BranchMetaData UnknownBranch = new()
87+
{
88+
Name = ConfigurationConstants.UnknownBranchKey,
89+
RegexPattern = ConfigurationConstants.UnknownBranchRegex
90+
};
91+
4492
protected ConfigurationBuilderBase()
4593
{
4694
if (GetType() != typeof(TConfigurationBuilder))
@@ -432,7 +480,7 @@ private static void ValidateConfiguration(GitVersionConfiguration configuration)
432480
}
433481
}
434482

435-
public record BranchMetaData
483+
protected record BranchMetaData
436484
{
437485
public string Name { get; init; }
438486

src/GitVersion.Core/Configuration/GitFlowConfigurationBuilder.cs

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -167,52 +167,4 @@ private GitFlowConfigurationBuilder()
167167
}
168168
});
169169
}
170-
171-
public static readonly BranchMetaData MainBranch = new()
172-
{
173-
Name = ConfigurationConstants.MainBranchKey,
174-
RegexPattern = ConfigurationConstants.MainBranchRegex
175-
};
176-
177-
public static readonly BranchMetaData DevelopBranch = new()
178-
{
179-
Name = ConfigurationConstants.DevelopBranchKey,
180-
RegexPattern = ConfigurationConstants.DevelopBranchRegex
181-
};
182-
183-
public static readonly BranchMetaData ReleaseBranch = new()
184-
{
185-
Name = ConfigurationConstants.ReleaseBranchKey,
186-
RegexPattern = ConfigurationConstants.ReleaseBranchRegex
187-
};
188-
189-
public static readonly BranchMetaData FeatureBranch = new()
190-
{
191-
Name = ConfigurationConstants.FeatureBranchKey,
192-
RegexPattern = ConfigurationConstants.FeatureBranchRegex
193-
};
194-
195-
public static readonly BranchMetaData PullRequestBranch = new()
196-
{
197-
Name = ConfigurationConstants.PullRequestBranchKey,
198-
RegexPattern = ConfigurationConstants.PullRequestBranchRegex
199-
};
200-
201-
public static readonly BranchMetaData HotfixBranch = new()
202-
{
203-
Name = ConfigurationConstants.HotfixBranchKey,
204-
RegexPattern = ConfigurationConstants.HotfixBranchRegex
205-
};
206-
207-
public static readonly BranchMetaData SupportBranch = new()
208-
{
209-
Name = ConfigurationConstants.SupportBranchKey,
210-
RegexPattern = ConfigurationConstants.SupportBranchRegex
211-
};
212-
213-
public static readonly BranchMetaData UnknownBranch = new()
214-
{
215-
Name = ConfigurationConstants.UnknownBranchKey,
216-
RegexPattern = ConfigurationConstants.UnknownBranchRegex
217-
};
218170
}

src/GitVersion.Core/Configuration/GitHubFlowConfigurationBuilder.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,34 +111,4 @@ private GitHubFlowConfigurationBuilder()
111111
}
112112
});
113113
}
114-
115-
public static readonly BranchMetaData MainBranch = new()
116-
{
117-
Name = ConfigurationConstants.MainBranchKey,
118-
RegexPattern = ConfigurationConstants.MainBranchRegex
119-
};
120-
121-
public static readonly BranchMetaData ReleaseBranch = new()
122-
{
123-
Name = ConfigurationConstants.ReleaseBranchKey,
124-
RegexPattern = ConfigurationConstants.ReleaseBranchRegex
125-
};
126-
127-
public static readonly BranchMetaData FeatureBranch = new()
128-
{
129-
Name = ConfigurationConstants.FeatureBranchKey,
130-
RegexPattern = ConfigurationConstants.FeatureBranchRegex
131-
};
132-
133-
public static readonly BranchMetaData PullRequestBranch = new()
134-
{
135-
Name = ConfigurationConstants.PullRequestBranchKey,
136-
RegexPattern = ConfigurationConstants.PullRequestBranchRegex
137-
};
138-
139-
public static readonly BranchMetaData UnknownBranch = new()
140-
{
141-
Name = ConfigurationConstants.UnknownBranchKey,
142-
RegexPattern = ConfigurationConstants.UnknownBranchRegex
143-
};
144114
}

0 commit comments

Comments
 (0)