Skip to content

Commit

Permalink
GitTools#2874 - added GitVersion.Scheme console that will generate th…
Browse files Browse the repository at this point in the history
…e json schemas
  • Loading branch information
arturcic committed Feb 26, 2023
1 parent a3e98e8 commit b29649b
Show file tree
Hide file tree
Showing 20 changed files with 1,032 additions and 130 deletions.
552 changes: 552 additions & 0 deletions schemas/6.0/GitVersion.configuration.json

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions schemas/6.0/GitVersion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://gitversion.net/schemas/6.0/GitVersion.json",
"title": "GitVersion version variables output",
"description": "GitVersion output schema",
"type": "object",
"properties": {
"AssemblySemFileVer": {
"description": "Suitable for .NET AssemblyFileVersion. Defaults to Major.Minor.Patch.0.",
"type": "string"
},
"AssemblySemVer": {
"description": "Suitable for .NET AssemblyVersion. Defaults to Major.Minor.0.0",
"type": "string"
},
"BranchName": {
"description": "The name of the checked out Git branch.",
"type": "string"
},
"BuildMetaData": {
"description": "The build metadata, usually representing number of commits since the VersionSourceSha.",
"type": [
"integer",
"null"
]
},
"CommitDate": {
"description": "The ISO-8601 formatted date of the commit identified by Sha.",
"type": "string"
},
"CommitsSinceVersionSource": {
"description": "The number of commits since the version source.",
"type": [
"integer",
"null"
]
},
"EscapedBranchName": {
"description": "Equal to BranchName, but with / replaced with -.",
"type": "string"
},
"FullBuildMetaData": {
"description": "The BuildMetaData suffixed with BranchName and Sha.",
"type": "string"
},
"FullSemVer": {
"description": "The full, SemVer 2.0 compliant version number.",
"type": "string"
},
"InformationalVersion": {
"description": "Suitable for .NET AssemblyInformationalVersion. Defaults to FullSemVer suffixed by FullBuildMetaData.",
"type": "string"
},
"Major": {
"description": "The major version. Should be incremented on breaking changes.",
"type": [
"integer",
"null"
]
},
"MajorMinorPatch": {
"description": "Major, Minor and Patch joined together, separated by \u0027.\u0027.",
"type": "string"
},
"Minor": {
"description": "The minor version. Should be incremented on new features.",
"type": [
"integer",
"null"
]
},
"Patch": {
"description": "The patch version. Should be incremented on bug fixes.",
"type": [
"integer",
"null"
]
},
"PreReleaseLabel": {
"description": "The pre-release label is the name of the pre-release.",
"type": "string"
},
"PreReleaseLabelWithDash": {
"description": "The pre-release label prefixed with a dash.",
"type": "string"
},
"PreReleaseNumber": {
"description": "The pre-release number is the number of commits since the last version bump.",
"type": [
"integer",
"null"
]
},
"PreReleaseTag": {
"description": "The pre-release tag is the pre-release label suffixed by the PreReleaseNumber.",
"type": "string"
},
"PreReleaseTagWithDash": {
"description": "The pre-release tag prefixed with a dash.",
"type": "string"
},
"SemVer": {
"description": "The semantical version number, including PreReleaseTagWithDash for pre-release version numbers.",
"type": "string"
},
"Sha": {
"description": "The SHA of the Git commit.",
"type": "string"
},
"ShortSha": {
"description": "The Sha limited to 7 characters.",
"type": "string"
},
"UncommittedChanges": {
"description": "The number of uncommitted changes present in the repository.",
"type": [
"integer",
"null"
]
},
"VersionSourceSha": {
"description": "The SHA of the commit used as version source.",
"type": "string"
},
"WeightedPreReleaseNumber": {
"description": "A summation of branch specific pre-release-weight and the PreReleaseNumber. Can be used to obtain a monotonically increasing version number across the branches.",
"type": [
"integer",
"null"
]
}
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PackageReference Include="System.Text.Json"/>
<PackageReference Include="System.Text.Encodings.Web"/>
</ItemGroup>
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'false' ">
<ItemGroup Condition=" '$(IsUnitTestProject)' == 'false' and $(MSBuildProjectName.EndsWith('.Schema')) == 'false'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 3 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="FluentDateTime" Version="2.1.0"/>
<PackageVersion Include="JsonSchema.Net.Generation" Version="3.0.3"/>
<PackageVersion Include="LibGit2Sharp" Version="0.27.0-preview-0182"/>
<PackageVersion Include="LibGit2Sharp.NativeBinaries" Version="2.0.315-alpha.0.9"/>
<PackageVersion Include="JetBrains.Annotations" Version="2022.3.1"/>

<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.4.0"/>
<PackageVersion Include="Microsoft.Build" Version="17.3.2"/>
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4"/>
<PackageVersion Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
Expand All @@ -37,4 +39,4 @@
<PackageVersion Include="System.Text.Encodings.Web" Version="7.0.0"/>
<PackageVersion Include="YamlDotNet" Version="13.0.1"/>
</ItemGroup>
</Project>
</Project>
17 changes: 17 additions & 0 deletions src/GitVersion.Core/Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GitVersion.Attributes;
using GitVersion.VersionCalculation;

namespace GitVersion.Configuration;
Expand Down Expand Up @@ -29,51 +30,67 @@ public BranchConfiguration(BranchConfiguration branchConfiguration)
}

[JsonPropertyName("mode")]
[JsonPropertyDescription("The versioning mode for this branch. Can be 'ContinuousDelivery', 'ContinuousDeployment', 'Mainline'.")]
public VersioningMode? VersioningMode { get; set; }

/// <summary>
/// Special value 'useBranchName' will extract the tag from the branch name
/// </summary>
[JsonPropertyName("label")]
[JsonPropertyDescription("The label to use for this branch. Can be 'useBranchName' to extract the label from the branch name. Use the value {BranchName} as a placeholder to insert the branch name.")]
public string? Label { get; set; }

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

[JsonPropertyName("prevent-increment-of-merged-branch-version")]
[JsonPropertyDescription("Prevent increment of merged branch version.")]
public bool? PreventIncrementOfMergedBranchVersion { get; set; }

[JsonPropertyName("label-number-pattern")]
[JsonPropertyDescription(@"The regex pattern to use to extract the number from the branch name. Defaults to '[/-](?<number>\d+)[-/]'.")]
[JsonPropertyPattern(@"[/-](?<number>\d+)[-/]")]
public string? LabelNumberPattern { get; set; }

[JsonPropertyName("track-merge-target")]
[JsonPropertyDescription("Strategy which will look for tagged merge commits directly off the current branch.")]
public bool? TrackMergeTarget { get; 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; 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; set; }

[JsonPropertyName("regex")]
[JsonPropertyDescription("The regex pattern to use to match this branch.")]
public string? Regex { get; set; }

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

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

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

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

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

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

/// <summary>
Expand Down
25 changes: 24 additions & 1 deletion src/GitVersion.Core/Configuration/GitVersionConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using GitVersion.Attributes;
using GitVersion.Extensions;

namespace GitVersion.Configuration;
Expand All @@ -14,24 +15,31 @@ public GitVersionConfiguration()
}

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

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

[JsonPropertyName("assembly-informational-format")]
[JsonPropertyDescription("Specifies the format of AssemblyInformationalVersion. The default value is {InformationalVersion}.")]
public string? AssemblyInformationalFormat { get; set; }

[JsonPropertyName("assembly-versioning-format")]
[JsonPropertyDescription("Specifies the format of AssemblyVersion and overwrites the value of assembly-versioning-scheme.")]
public string? AssemblyVersioningFormat { get; 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; set; }

[JsonPropertyName("label-prefix")]
[JsonPropertyDescription($"A regex which is used to trim Git tags before processing. Defaults to {ConfigurationConstants.DefaultLabelPrefix}")]
public string? LabelPrefix { get; 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;
Expand All @@ -42,36 +50,52 @@ public string? NextVersion
}

[JsonPropertyName("major-version-bump-message")]
[JsonPropertyDescription(@"The regex to match commit messages with to perform a major version increment. Default set to '\+semver:\s?(breaking|major)'")]
[JsonPropertyPattern(@"'\+semver:\s?(breaking|major)'")]
public string? MajorVersionBumpMessage { get; set; }

[JsonPropertyName("minor-version-bump-message")]
[JsonPropertyDescription(@"The regex to match commit messages with to perform a minor version increment. Default set to '\+semver:\s?(feature|minor)'")]
[JsonPropertyPattern(@"'\+semver:\s?(feature|minor)'")]
public string? MinorVersionBumpMessage { get; set; }

[JsonPropertyName("patch-version-bump-message")]
[JsonPropertyDescription(@"The regex to match commit messages with to perform a patch version increment. Default set to '\+semver:\s?(fix|patch)'")]
[JsonPropertyPattern(@"'\+semver:\s?(fix|patch)'")]
public string? PatchVersionBumpMessage { get; set; }

[JsonPropertyName("no-bump-message")]
[JsonPropertyDescription(@"Used to tell GitVersion not to increment when in Mainline development mode. . Default set to '\+semver:\s?(none|skip)'")]
[JsonPropertyPattern(@"'\+semver:\s?(none|skip)'")]
public string? NoBumpMessage { get; set; }

[JsonPropertyName("label-pre-release-weight")]
[JsonPropertyDescription("The pre-release weight in case of tagged commits. Defaults to 60000.")]
public int? LabelPreReleaseWeight { get; set; }

[JsonPropertyName("commit-date-format")]
[JsonPropertyDescription("The format to use when calculating the commit date. Defaults to 'yyyy-MM-dd'.")]
[JsonPropertyPattern("'yyyy-MM-dd'", PatternFormat.DateTime)]
public string? CommitDateFormat { get; 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; set; } = new();

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

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

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

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

public override string ToString()
Expand All @@ -82,5 +106,4 @@ public override string ToString()
stream.Flush();
return stringBuilder.ToString();
}

}
4 changes: 4 additions & 0 deletions src/GitVersion.Core/Configuration/IgnoreConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GitVersion.Attributes;
using GitVersion.VersionCalculation;

namespace GitVersion.Configuration;
Expand All @@ -7,9 +8,12 @@ public class IgnoreConfiguration
public IgnoreConfiguration() => Shas = Array.Empty<string>();

[JsonPropertyName("commits-before")]
[JsonPropertyDescription("Commits before this date will be ignored. Format: yyyy-MM-ddTHH:mm:ss.")]
[JsonPropertyPattern(@"'yyyy-MM-ddTHH:mm:ss'", PatternFormat.DateTime)]
public DateTimeOffset? Before { get; set; }

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

[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace GitVersion.Attributes;

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public sealed class JsonPropertyDescriptionAttribute : JsonAttribute
{
/// <summary>
/// Initializes a new instance of <see cref="JsonPropertyDescriptionAttribute"/> with the specified property description.
/// </summary>
/// <param name="description">The description of the property.</param>
public JsonPropertyDescriptionAttribute(string description) => Description = description;

/// <summary>
/// The description of the property.
/// </summary>
public string Description { get; }
}
Loading

0 comments on commit b29649b

Please sign in to comment.