Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2325 - remove legacy variables #3130

Merged
merged 1 commit into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion build/build/Tasks/Package/PackageChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Run(BuildContext context)
var chocolateySettings = new ChocolateyPackSettings
{
LimitOutput = true,
Version = context.Version?.SemVersion,
Version = context.Version?.ChocolateyVersion,
OutputDirectory = Paths.Nuget,
Files = context.GetFiles(artifactPath + "/**/*.*")
.Select(file => new ChocolateyNuSpecContent { Source = file.FullPath, Target = file.FullPath.Replace(artifactPath, "") })
Expand Down
30 changes: 0 additions & 30 deletions build/common/Addins/GitVersion/GitVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public sealed class GitVersion
/// </summary>
public string? BuildMetaData { get; set; }

/// <summary>
/// Gets or sets the build metadata padded.
/// </summary>
public string? BuildMetaDataPadded { get; set; }

/// <summary>
/// Gets or sets the major version.
/// </summary>
Expand All @@ -65,16 +60,6 @@ public sealed class GitVersion
/// </summary>
public string? SemVer { get; set; }

/// <summary>
/// Gets or sets the legacy Semantic Version.
/// </summary>
public string? LegacySemVer { get; set; }

/// <summary>
/// Gets or sets the padded legacy Semantic Version.
/// </summary>
public string? LegacySemVerPadded { get; set; }

/// <summary>
/// Gets or sets the assembly Semantic Version.
/// </summary>
Expand Down Expand Up @@ -105,26 +90,11 @@ public sealed class GitVersion
/// </summary>
public string? Sha { get; set; }

/// <summary>
/// Gets or sets the NuGet version for v2.
/// </summary>
public string? NuGetVersionV2 { get; set; }

/// <summary>
/// Gets or sets the NuGet version.
/// </summary>
public string? NuGetVersion { get; set; }

/// <summary>
/// Gets or sets the commits since version source.
/// </summary>
public int? CommitsSinceVersionSource { get; set; }

/// <summary>
/// Gets or sets the commits since version source padded.
/// </summary>
public string? CommitsSinceVersionSourcePadded { get; set; }

/// <summary>
/// Gets or sets the commit date.
/// </summary>
Expand Down
16 changes: 12 additions & 4 deletions build/common/Utilities/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ public record NugetCredentials(string ApiKey);

public record ChocolateyCredentials(string ApiKey);

public record BuildVersion(GitVersion GitVersion, string? Version, string? Milestone, string? SemVersion, string? NugetVersion)
public record BuildVersion(GitVersion GitVersion, string? Version, string? Milestone, string? SemVersion, string? NugetVersion, string? ChocolateyVersion)
{
public static BuildVersion Calculate(GitVersion gitVersion)
{
var version = gitVersion.MajorMinorPatch;
var semVersion = gitVersion.LegacySemVer;
var nugetVersion = gitVersion.LegacySemVer;
var semVersion = gitVersion.SemVer;
var nugetVersion = gitVersion.SemVer;
var chocolateyVersion = gitVersion.MajorMinorPatch;

if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseTag))
{
chocolateyVersion += $"-{gitVersion.PreReleaseTag?.Replace(".", "-")}";
}

if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaData))
{
semVersion += $"-{gitVersion.BuildMetaData}";
chocolateyVersion += $"-{gitVersion.BuildMetaData}";
nugetVersion += $".{gitVersion.BuildMetaData}";
}

Expand All @@ -31,7 +38,8 @@ public static BuildVersion Calculate(GitVersion gitVersion)
Version: version,
Milestone: version,
SemVersion: semVersion,
NugetVersion: nugetVersion?.ToLowerInvariant()
NugetVersion: nugetVersion?.ToLowerInvariant(),
ChocolateyVersion: chocolateyVersion?.ToLowerInvariant()
);
}
}
Expand Down
21 changes: 0 additions & 21 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
tag-pre-release-weight: 60000
commit-message-incrementing: Enabled
ignore:
Expand Down Expand Up @@ -194,24 +191,6 @@ Used to tell GitVersion not to increment when in Mainline development mode.
Default `\+semver:\s?(none|skip)`, which will match occurrences of `+semver:
none` and `+semver: skip`

### legacy-semver-padding

The number of characters to pad `LegacySemVer` to in the `LegacySemVerPadded`
[variable][variables]. Default is `4`, which will pad the `LegacySemVer` value
of `3.0.0-beta1` to `3.0.0-beta0001`.

### build-metadata-padding

The number of characters to pad `BuildMetaData` to in the `BuildMetaDataPadded`
[variable][variables]. Default is `4`, which will pad the `BuildMetaData` value
of `1` to `0001`.

### commits-since-version-source-padding

The number of characters to pad `CommitsSinceVersionSource` to in the
`CommitsSinceVersionSourcePadded` [variable][variables]. Default is `4`, which
will pad the `CommitsSinceVersionSource` value of `1` to `0001`.

### tag-pre-release-weight

The pre-release weight in case of tagged commits. If the value is not set in the
Expand Down
16 changes: 0 additions & 16 deletions docs/input/docs/reference/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows:
"PreReleaseNumber": 99,
"WeightedPreReleaseNumber": 1099,
"BuildMetaData": 88,
"BuildMetaDataPadded": "0088",
"FullBuildMetaData": "99.Branch.release/3.22.11.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"MajorMinorPatch": "3.22.11",
"SemVer": "3.22.11-beta.99",
"LegacySemVer": "3.22.11-beta99",
"LegacySemVerPadded": "3.22.11-beta0099",
"AssemblySemVer": "3.22.11.0",
"AssemblySemFileVer": "3.22.11.0",
"InformationalVersion": "3.22.11-beta.99+88.Branch.release/3.022.011.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
Expand All @@ -35,13 +32,8 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows:
"EscapedBranchName": "release-3.022.011",
"Sha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"ShortSha": "28c8531",
"NuGetVersionV2": "3.22.11-beta0099",
"NuGetVersion": "3.22.11-beta0099",
"NuGetPreReleaseTagV2": "beta0099",
"NuGetPreReleaseTag": "beta0099",
"VersionSourceSha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"CommitsSinceVersionSource": 7,
"CommitsSinceVersionSourcePadded": "0007",
"CommitDate": "2021-12-31",
"UncommittedChanges": 0
}
Expand All @@ -61,12 +53,9 @@ Each property of the above JSON document is described in the below table.
| `PreReleaseNumber` | The pre-release number. |
| `WeightedPreReleaseNumber` | A summation of branch specific `pre-release-weight` and the `PreReleaseNumber`. Can be used to obtain a monotonically increasing version number across the branches. |
| `BuildMetaData` | The build metadata, usually representing number of commits since the `VersionSourceSha`. Despite its name, will not increment for every build. |
| `BuildMetaDataPadded` | The `BuildMetaData` padded with `0` up to 4 digits. |
| `FullBuildMetaData` | The `BuildMetaData` suffixed with `BranchName` and `Sha`. |
| `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. |
| `SemVer` | The semantical version number, including `PreReleaseTagWithDash` for pre-release version numbers. |
| `LegacySemVer` | Equal to `SemVer`, but without a `.` separating `PreReleaseLabel` and `PreReleaseNumber`. |
| `LegacySemVerPadded` | Equal to `LegacySemVer`, but with `PreReleaseNumber` padded with `0` up to 4 digits. |
| `AssemblySemVer` | Suitable for .NET `AssemblyVersion`. Defaults to `Major.Minor.0.0` to allow the assembly to be hotfixed without breaking existing applications that may be referencing it. |
| `AssemblySemFileVer` | Suitable for .NET `AssemblyFileVersion`. Defaults to `Major.Minor.Patch.0`. |
| `InformationalVersion` | Suitable for .NET `AssemblyInformationalVersion`. Defaults to `FullSemVer` suffixed by `FullBuildMetaData`. |
Expand All @@ -75,13 +64,8 @@ Each property of the above JSON document is described in the below table.
| `EscapedBranchName` | Equal to `BranchName`, but with `/` replaced with `-`. |
| `Sha` | The SHA of the Git commit. |
| `ShortSha` | The `Sha` limited to 7 characters. |
| `NuGetVersionV2` | A NuGet 2.0 compatible version number. |
| `NuGetVersion` | A NuGet 1.0 compatible version number. |
| `NuGetPreReleaseTagV2` | A NuGet 2.0 compatible `PreReleaseTag`. |
| `NuGetPreReleaseTag` | A NuGet 1.0 compatible `PreReleaseTag`. |
| `VersionSourceSha` | The SHA of the commit used as version source. |
| `CommitsSinceVersionSource` | The number of commits since the version source. |
| `CommitsSinceVersionSourcePadded` | The `CommitsSinceVersionSource` padded with `0` up to 4 digits. |
| `CommitDate` | The ISO-8601 formatted date of the commit identified by `Sha`. |
| `UncommittedChanges` | The number of uncommitted changes present in the repository. |

Expand Down
3 changes: 0 additions & 3 deletions docs/input/docs/usage/cli/arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,10 @@ Following options are supported:
3. `assembly-informational-format`
4. `assembly-versioning-format`
5. `assembly-versioning-scheme`
6. `build-metadata-padding`
7. `commit-date-format`
8. `commit-message-incrementing`
9. `commits-since-version-source-padding`
10. `continuous-delivery-fallback-tag`
11. `increment`
12. `legacy-semver-padding`
13. `major-version-bump-message`
14. `minor-version-bump-message`
15. `mode`
Expand Down
27 changes: 3 additions & 24 deletions src/GitVersion.App.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ private static IEnumerable<TestCaseData> OverrideconfigWithInvalidOptionTestData
};
}

[TestCaseSource(nameof(OverrideconfigWithSingleOptionTestData))]
public void OverrideconfigWithSingleOptions(string options, Config expected)
[TestCaseSource(nameof(OverrideConfigWithSingleOptionTestData))]
public void OverrideConfigWithSingleOptions(string options, Config expected)
{
var arguments = this.argumentParser.ParseArguments($"/overrideconfig {options}");
arguments.OverrideConfig.ShouldBeEquivalentTo(expected);
}

private static IEnumerable<TestCaseData> OverrideconfigWithSingleOptionTestData()
private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData()
{
yield return new TestCaseData(
"assembly-versioning-scheme=MajorMinor",
Expand Down Expand Up @@ -509,27 +509,6 @@ private static IEnumerable<TestCaseData> OverrideconfigWithSingleOptionTestData(
NoBumpMessage = "This is no bump message."
}
);
yield return new TestCaseData(
"legacy-semver-padding=99",
new Config
{
LegacySemVerPadding = 99
}
);
yield return new TestCaseData(
"build-metadata-padding=30",
new Config
{
BuildMetaDataPadding = 30
}
);
yield return new TestCaseData(
"commits-since-version-source-padding=5",
new Config
{
CommitsSinceVersionSourcePadding = 5
}
);
yield return new TestCaseData(
"tag-pre-release-weight=2",
new Config
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static async Task VerifyPullRequestVersionIsCalculatedProperly(string pu

result.ExitCode.ShouldBe(0);
result.OutputVariables.ShouldNotBeNull();
result.OutputVariables.FullSemVer.ShouldBe("1.0.4-PullRequest0005.3");
result.OutputVariables.FullSemVer.ShouldBe("1.0.4-PullRequest5.3");

// Cleanup repository files
DirectoryHelper.DeleteDirectory(remoteRepositoryPath);
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersion.App.Tests/VersionWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public void WriteVersionShouldWriteFileVersionWithNoPrereleaseTag()
[Test]
public void WriteVersionShouldWriteFileVersionWithPrereleaseTag()
{
var asm = GenerateAssembly(new Version(1, 0, 0), "-beta0004");
var asm = GenerateAssembly(new Version(1, 0, 0), "-beta4");

string? version = string.Empty;
this.versionWriter.WriteTo(asm, v => version = v);

Assert.IsNotNull(asm);
Assert.AreEqual("1.0.0-beta0004", version);
Assert.AreEqual("1.0.0-beta4", version);
}

private static Assembly GenerateAssembly(Version fileVersion, string prereleaseInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Core.Tests/BuildAgents/MyGetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void EscapeValues()
[Test]
public void BuildNumber()
{
var message = this.buildServer.GenerateSetParameterMessage("LegacySemVerPadded", "0.8.0-unstable568");
var message = this.buildServer.GenerateSetParameterMessage("SemVer", "0.8.0-unstable568");
Assert.AreEqual("##myget[buildNumber '0.8.0-unstable568']", message[1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
tag-pre-release-weight: 60000
commit-message-incrementing: Enabled
branches:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,6 @@ public void ShouldNotOverrideAnythingWhenOverrideConfigIsEmpty()
overridenConfig.MinorVersionBumpMessage.ShouldBe(expectedConfig.MinorVersionBumpMessage);
overridenConfig.PatchVersionBumpMessage.ShouldBe(expectedConfig.PatchVersionBumpMessage);
overridenConfig.NoBumpMessage.ShouldBe(expectedConfig.NoBumpMessage);
overridenConfig.LegacySemVerPadding.ShouldBe(expectedConfig.LegacySemVerPadding);
overridenConfig.BuildMetaDataPadding.ShouldBe(expectedConfig.BuildMetaDataPadding);
overridenConfig.CommitsSinceVersionSourcePadding.ShouldBe(expectedConfig.CommitsSinceVersionSourcePadding);
overridenConfig.TagPreReleaseWeight.ShouldBe(expectedConfig.TagPreReleaseWeight);
overridenConfig.CommitMessageIncrementing.ShouldBe(expectedConfig.CommitMessageIncrementing);
overridenConfig.Increment.ShouldBe(expectedConfig.Increment);
Expand Down
Loading