Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<PackageVersion Include="System.Security.Cryptography.Xml" Version="9.0.7" />
<PackageVersion Include="System.Text.Json" Version="9.0.9" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.3.0" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
</ItemGroup>
</Project>
28 changes: 14 additions & 14 deletions src/GitVersion.Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,72 @@ internal record BranchConfiguration : IBranchConfiguration
{
[JsonPropertyName("mode")]
[JsonPropertyDescription("The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.")]
public DeploymentMode? DeploymentMode { get; internal init; }
public DeploymentMode? DeploymentMode { get; internal set; }

[JsonPropertyName("label")]
[JsonPropertyDescription("The label to use for this branch. Use the value {BranchName} or similar as a placeholder to insert a named capture group from RegularExpression (fx. the branch name).")]
public string? Label { get; internal init; }
public string? Label { get; internal set; }

[JsonPropertyName("increment")]
[JsonPropertyDescription("The increment strategy for this branch. Can be 'Inherit', 'Patch', 'Minor', 'Major', 'None'.")]
public IncrementStrategy Increment { get; internal init; }
public IncrementStrategy Increment { get; internal set; }

[JsonIgnore]
IPreventIncrementConfiguration IBranchConfiguration.PreventIncrement => PreventIncrement;

[JsonPropertyName("prevent-increment")]
[JsonPropertyDescription("The prevent increment configuration section.")]
public PreventIncrementConfiguration PreventIncrement { get; internal init; } = new();
public PreventIncrementConfiguration PreventIncrement { get; internal set; } = new();

[JsonPropertyName("track-merge-target")]
[JsonPropertyDescription("Strategy which will look for tagged merge commits directly off the current branch.")]
public bool? TrackMergeTarget { get; internal init; }
public bool? TrackMergeTarget { get; internal set; }

[JsonPropertyName("track-merge-message")]
[JsonPropertyDescription("This property is a branch related property and gives the user the possibility to control the behavior of whether the merge commit message will be interpreted as a next version or not.")]
public bool? TrackMergeMessage { get; internal init; }
public bool? TrackMergeMessage { get; internal set; }

[JsonPropertyName("commit-message-incrementing")]
[JsonPropertyDescription("Sets whether it should be possible to increment the version with special syntax in the commit message. Can be 'Disabled', 'Enabled' or 'MergeMessageOnly'.")]
public CommitMessageIncrementMode? CommitMessageIncrementing { get; internal init; }
public CommitMessageIncrementMode? CommitMessageIncrementing { get; internal set; }

[JsonPropertyName("regex")]
[JsonPropertyDescription("The regular expression pattern to use to match this branch.")]
[JsonPropertyFormat(Format.Regex)]
public string? RegularExpression { get; internal init; }
public string? RegularExpression { get; internal set; }

[JsonIgnore]
string? IBranchConfiguration.RegularExpression => RegularExpression;

[JsonPropertyName("source-branches")]
[JsonPropertyDescription("The source branches for this branch.")]
public HashSet<string> SourceBranches { get; internal init; } = [];
public HashSet<string> SourceBranches { get; internal set; } = [];

[JsonIgnore]
IReadOnlyCollection<string> IBranchConfiguration.SourceBranches => SourceBranches;

[JsonPropertyName("is-source-branch-for")]
[JsonPropertyDescription("The branches that this branch is a source branch.")]
public HashSet<string> IsSourceBranchFor { get; internal init; } = [];
public HashSet<string> IsSourceBranchFor { get; internal set; } = [];

[JsonIgnore]
IReadOnlyCollection<string> IBranchConfiguration.IsSourceBranchFor => IsSourceBranchFor;

[JsonPropertyName("tracks-release-branches")]
[JsonPropertyDescription("Indicates this branch configuration represents develop in GitFlow.")]
public bool? TracksReleaseBranches { get; internal init; }
public bool? TracksReleaseBranches { get; internal set; }

[JsonPropertyName("is-release-branch")]
[JsonPropertyDescription("Indicates this branch configuration represents a release branch in GitFlow.")]
public bool? IsReleaseBranch { get; internal init; }
public bool? IsReleaseBranch { get; internal set; }

[JsonPropertyName("is-main-branch")]
[JsonPropertyDescription("When using Mainline mode, this indicates that this branch is a mainline. By default main and support/* are mainlines.")]
public bool? IsMainBranch { get; internal init; }
public bool? IsMainBranch { get; internal set; }

[JsonPropertyName("pre-release-weight")]
[JsonPropertyDescription("Provides a way to translate the PreReleaseLabel to a number.")]
public int? PreReleaseWeight { get; internal init; }
public int? PreReleaseWeight { get; internal set; }

public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration)
{
Expand Down
4 changes: 4 additions & 0 deletions src/GitVersion.Configuration/ConfigurationSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ namespace GitVersion.Configuration;

internal class ConfigurationSerializer : IConfigurationSerializer
{
// Static context is defined for future AOT support but not currently used
// due to limitations with custom type inspectors and init properties
private static readonly GitVersionConfigurationStaticContext staticContext = new();
Copy link
Member

@arturcic arturcic Oct 8, 2025

Choose a reason for hiding this comment

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

@copilot I actually need to use the source generator version, and I will later check the AOT


private static IDeserializer Deserializer => new DeserializerBuilder()
.WithNamingConvention(HyphenatedNamingConvention.Instance)
.WithTypeConverter(VersionStrategiesConverter.Instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
42 changes: 21 additions & 21 deletions src/GitVersion.Configuration/GitVersionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@ internal sealed record GitVersionConfiguration : BranchConfiguration, IGitVersio
{
[JsonPropertyName("workflow")]
[JsonPropertyDescription("The base template of the configuration to use. Possible values are: 'GitFlow/v1' or 'GitHubFlow/v1'")]
public string? Workflow { get; internal init; }
public string? Workflow { get; internal set; }

[JsonPropertyName("assembly-versioning-scheme")]
[JsonPropertyDescription($"The scheme to use when setting AssemblyVersion attribute. Can be 'MajorMinorPatchTag', 'MajorMinorPatch', 'MajorMinor', 'Major', 'None'. Defaults to '{NameOfDefaultAssemblyVersioningScheme}'.")]
[JsonPropertyDefault(DefaultAssemblyVersioningScheme)]
public AssemblyVersioningScheme? AssemblyVersioningScheme { get; internal init; }
public AssemblyVersioningScheme? AssemblyVersioningScheme { get; internal set; }

[JsonPropertyName("assembly-file-versioning-scheme")]
[JsonPropertyDescription($"The scheme to use when setting AssemblyFileVersion attribute. Can be 'MajorMinorPatchTag', 'MajorMinorPatch', 'MajorMinor', 'Major', 'None'. Defaults to '{NameOfDefaultAssemblyFileVersioningScheme}'.")]
[JsonPropertyDefault(DefaultAssemblyFileVersioningScheme)]
public AssemblyFileVersioningScheme? AssemblyFileVersioningScheme { get; internal init; }
public AssemblyFileVersioningScheme? AssemblyFileVersioningScheme { get; internal set; }

[JsonPropertyName("assembly-informational-format")]
[JsonPropertyDescription($"Specifies the format of AssemblyInformationalVersion. Defaults to '{DefaultAssemblyInformationalFormat}'.")]
[JsonPropertyDefault($"'{DefaultAssemblyInformationalFormat}'")]
public string? AssemblyInformationalFormat { get; internal init; }
public string? AssemblyInformationalFormat { get; internal set; }

[JsonPropertyName("assembly-versioning-format")]
[JsonPropertyDescription("Specifies the format of AssemblyVersion and overwrites the value of assembly-versioning-scheme.")]
public string? AssemblyVersioningFormat { get; internal init; }
public string? AssemblyVersioningFormat { get; internal set; }

[JsonPropertyName("assembly-file-versioning-format")]
[JsonPropertyDescription("Specifies the format of AssemblyFileVersion and overwrites the value of assembly-file-versioning-scheme.")]
public string? AssemblyFileVersioningFormat { get; internal init; }
public string? AssemblyFileVersioningFormat { get; internal set; }

[JsonPropertyName("tag-prefix")]
[JsonPropertyDescription($"A regular expression which is used to trim Git tags before processing. Defaults to '{RegexPatterns.Configuration.DefaultTagPrefixRegexPattern}'")]
[JsonPropertyDefault(RegexPatterns.Configuration.DefaultTagPrefixRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? TagPrefixPattern { get; internal init; }
public string? TagPrefixPattern { get; internal set; }

[JsonPropertyName("version-in-branch-pattern")]
[JsonPropertyDescription($"A regular expression which is used to determine the version number in the branch name or commit message (e.g., v1.0.0-LTS). Defaults to '{RegexPatterns.Configuration.DefaultVersionInBranchRegexPattern}'.")]
[JsonPropertyDefault(RegexPatterns.Configuration.DefaultVersionInBranchRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? VersionInBranchPattern { get; internal init; }
public string? VersionInBranchPattern { get; internal set; }

[JsonPropertyName("next-version")]
[JsonPropertyDescription("Allows you to bump the next version explicitly. Useful for bumping main or a feature branch with breaking changes")]
public string? NextVersion
{
get => nextVersion;
internal init =>
internal set =>
nextVersion = int.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out var major)
? $"{major}.0"
: value;
Expand All @@ -63,75 +63,75 @@ public string? NextVersion
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a major version increment. Defaults to '{RegexPatterns.VersionCalculation.DefaultMajorRegexPattern}'")]
[JsonPropertyDefault(RegexPatterns.VersionCalculation.DefaultMajorRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? MajorVersionBumpMessage { get; internal init; }
public string? MajorVersionBumpMessage { get; internal set; }

[JsonPropertyName("minor-version-bump-message")]
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a minor version increment. Defaults to '{RegexPatterns.VersionCalculation.DefaultMinorRegexPattern}'")]
[JsonPropertyDefault(RegexPatterns.VersionCalculation.DefaultMinorRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? MinorVersionBumpMessage { get; internal init; }
public string? MinorVersionBumpMessage { get; internal set; }

[JsonPropertyName("patch-version-bump-message")]
[JsonPropertyDescription($"The regular expression to match commit messages with to perform a patch version increment. Defaults to '{RegexPatterns.VersionCalculation.DefaultPatchRegexPattern}'")]
[JsonPropertyDefault(RegexPatterns.VersionCalculation.DefaultPatchRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? PatchVersionBumpMessage { get; internal init; }
public string? PatchVersionBumpMessage { get; internal set; }

[JsonPropertyName("no-bump-message")]
[JsonPropertyDescription($"Used to tell GitVersion not to increment when in Mainline development mode. Defaults to '{RegexPatterns.VersionCalculation.DefaultNoBumpRegexPattern}'")]
[JsonPropertyDefault(RegexPatterns.VersionCalculation.DefaultNoBumpRegexPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? NoBumpMessage { get; internal init; }
public string? NoBumpMessage { get; internal set; }

[JsonPropertyName("tag-pre-release-weight")]
[JsonPropertyDescription($"The pre-release weight in case of tagged commits. Defaults to {StringDefaultTagPreReleaseWeight}.")]
public int? TagPreReleaseWeight { get; internal init; }
public int? TagPreReleaseWeight { get; internal set; }

[JsonPropertyName("commit-date-format")]
[JsonPropertyDescription($"The format to use when calculating the commit date. Defaults to '{DefaultCommitDateFormat}'. See [Standard Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) and [Custom Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).")]
[JsonPropertyDefault(DefaultCommitDateFormat)]
[System.Diagnostics.CodeAnalysis.StringSyntax("DateTimeFormat")]
public string? CommitDateFormat { get; internal init; }
public string? CommitDateFormat { get; internal set; }

[JsonPropertyName("merge-message-formats")]
[JsonPropertyDescription("Custom merge message formats to enable identification of merge messages that do not follow the built-in conventions.")]
public Dictionary<string, string> MergeMessageFormats { get; internal init; } = [];
public Dictionary<string, string> MergeMessageFormats { get; internal set; } = [];

[JsonIgnore]
IReadOnlyDictionary<string, string> IGitVersionConfiguration.MergeMessageFormats => MergeMessageFormats;

[JsonPropertyName("update-build-number")]
[JsonPropertyDescription($"Whether to update the build number in the project file. Defaults to {StringDefaultUpdateBuildNumber}.")]
[JsonPropertyDefault(DefaultUpdateBuildNumber)]
public bool UpdateBuildNumber { get; internal init; } = DefaultUpdateBuildNumber;
public bool UpdateBuildNumber { get; internal set; } = DefaultUpdateBuildNumber;

[JsonPropertyName("semantic-version-format")]
[JsonPropertyDescription($"Specifies the semantic version format that is used when parsing the string. Can be 'Strict' or 'Loose'. Defaults to '{StringDefaultSemanticVersionFormat}'.")]
[JsonPropertyDefault(DefaultSemanticVersionFormat)]
public SemanticVersionFormat SemanticVersionFormat { get; internal init; }
public SemanticVersionFormat SemanticVersionFormat { get; internal set; }

[JsonIgnore]
VersionStrategies IGitVersionConfiguration.VersionStrategy => VersionStrategies.Length == 0
? VersionCalculation.VersionStrategies.None : VersionStrategies.Aggregate((one, another) => one | another);

[JsonPropertyName("strategies")]
[JsonPropertyDescription($"Specifies which version strategies (one or more) will be used to determine the next version. Following values are available: '{nameof(VersionCalculation.VersionStrategies.ConfiguredNextVersion)}', '{nameof(VersionCalculation.VersionStrategies.MergeMessage)}', '{nameof(VersionCalculation.VersionStrategies.TaggedCommit)}', '{nameof(VersionCalculation.VersionStrategies.TrackReleaseBranches)}', '{nameof(VersionCalculation.VersionStrategies.VersionInBranchName)}' and '{nameof(VersionCalculation.VersionStrategies.Mainline)}'.")]
public VersionStrategies[] VersionStrategies { get; internal init; } = [];
public VersionStrategies[] VersionStrategies { get; internal set; } = [];

[JsonIgnore]
IReadOnlyDictionary<string, IBranchConfiguration> IGitVersionConfiguration.Branches
=> Branches.ToDictionary(element => element.Key, IBranchConfiguration (element) => element.Value);

[JsonPropertyName("branches")]
[JsonPropertyDescription("The header for all the individual branch configuration.")]
public Dictionary<string, BranchConfiguration> Branches { get; internal init; } = [];
public Dictionary<string, BranchConfiguration> Branches { get; internal set; } = [];

[JsonIgnore]
IIgnoreConfiguration IGitVersionConfiguration.Ignore => Ignore;

[JsonPropertyName("ignore")]
[JsonPropertyDescription("The header property for the ignore configuration.")]
public IgnoreConfiguration Ignore { get; internal init; } = new();
public IgnoreConfiguration Ignore { get; internal set; } = new();

public override IBranchConfiguration Inherit(IBranchConfiguration configuration) => throw new NotSupportedException();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using YamlDotNet.Serialization;

namespace GitVersion.Configuration;

[YamlStaticContext]
[YamlSerializable(typeof(GitVersionConfiguration))]
[YamlSerializable(typeof(BranchConfiguration))]
[YamlSerializable(typeof(IgnoreConfiguration))]
[YamlSerializable(typeof(PreventIncrementConfiguration))]
public partial class GitVersionConfigurationStaticContext
{
}
8 changes: 4 additions & 4 deletions src/GitVersion.Configuration/IgnoreConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ namespace GitVersion.Configuration;
internal record IgnoreConfiguration : IIgnoreConfiguration
{
[JsonIgnore]
public DateTimeOffset? Before { get; init; }
public DateTimeOffset? Before { get; set; }

[JsonPropertyName("commits-before")]
[JsonPropertyDescription("Commits before this date will be ignored. Format: yyyy-MM-ddTHH:mm:ss.")]
[JsonPropertyFormat(Format.DateTime)]
public string? BeforeString
{
get => Before?.ToString("yyyy-MM-ddTHH:mm:ssZ");
init => Before = value is null ? null : DateTimeOffset.Parse(value);
set => Before = value is null ? null : DateTimeOffset.Parse(value);
}

[JsonIgnore]
IReadOnlySet<string> IIgnoreConfiguration.Shas => Shas;

[JsonPropertyName("sha")]
[JsonPropertyDescription("A sequence of SHAs to be excluded from the version calculations.")]
public HashSet<string> Shas { get; init; } = [];
public HashSet<string> Shas { get; set; } = [];

IReadOnlyCollection<string> IIgnoreConfiguration.Paths => Paths;

[JsonPropertyName("paths")]
[JsonPropertyDescription("A sequence of file paths to be excluded from the version calculations.")]
public Collection<string> Paths { get; init; } = [];
public Collection<string> Paths { get; set; } = [];

[JsonIgnore]
public bool IsEmpty => Before == null && Shas.Count == 0 && Paths.Count == 0;
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersion.Configuration/PreventIncrementConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ internal class PreventIncrementConfiguration : IPreventIncrementConfiguration
{
[JsonPropertyName("of-merged-branch")]
[JsonPropertyDescription("Prevent increment when branch merged.")]
public bool? OfMergedBranch { get; internal init; }
public bool? OfMergedBranch { get; internal set; }

[JsonPropertyName("when-branch-merged")]
[JsonPropertyDescription("Prevent increment when branch merged.")]
public bool? WhenBranchMerged { get; internal init; }
public bool? WhenBranchMerged { get; internal set; }

[JsonPropertyName("when-current-commit-tagged")]
[JsonPropertyDescription("This branch related property controls the behavior whether to use the tagged (value set to true) or the incremented (value set to false) semantic version. Defaults to true.")]
public bool? WhenCurrentCommitTagged { get; internal init; }
public bool? WhenCurrentCommitTagged { get; internal set; }
}
Loading
Loading