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

Variable provider updates #343

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions BREAKING CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
v3.0.0
- `AssemblyFileSemVer` variable removed, AssemblyVersioningScheme configuration value makes this variable obsoluete
- `ClassicVersion` variable removed,
- `ClassicVersionWithTag` variable removed, as above
- MSBuild task arguments (AssemblyVersioningScheme, DevelopBranchTag, ReleaseBranchTag, TagPrefix, NextVersion) have been removed, use GitVersionConfig.yaml instead
2 changes: 2 additions & 0 deletions GitVersion.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore.Tests", "Git
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3EFFC5D6-88D0-49D9-BB53-E1B7EB49DD45}"
ProjectSection(SolutionItems) = preProject
BREAKING CHANGES.md = BREAKING CHANGES.md
GitVersionConfig.yaml = GitVersionConfig.yaml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
Expand Down
1 change: 1 addition & 0 deletions GitVersion.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleMistakenCallToGetType_002E2/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleNullReferenceException/@EntryIndexedValue">WARNING</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PrivateFieldCanBeConvertedToLocalVariable/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentName/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentNameForLiteralExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAssignment/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantBaseConstructorCall/@EntryIndexedValue">ERROR</s:String>
Expand Down
4 changes: 2 additions & 2 deletions GitVersionConfig.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
assembly-versioning-scheme: MajorMinor
next-version: 2.0.0
assembly-versioning-scheme: MajorMinorPatch
next-version: 3.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
"LegacySemVer":"1.2.3-unstable4",
"LegacySemVerPadded":"1.2.3-unstable0004",
"AssemblySemVer":"1.2.3.0",
"AssemblyFileSemVer":"1.2.3.0",
"FullSemVer":"1.2.3-unstable.4+5",
"InformationalVersion":"1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha",
"ClassicVersion":"1.2.3.5",
"ClassicVersionWithTag":"1.2.3.5-unstable.4",
"BranchName":"feature1",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0004",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Major":1,
"Minor":2,
"Patch":3,
"PreReleaseTag":"unstable.4",
"PreReleaseTagWithDash":"-unstable.4",
"BuildMetaData":5,
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",
"MajorMinorPatch":"1.2.3",
"SemVer":"1.2.3-unstable.4",
"LegacySemVer":"1.2.3-unstable4",
"LegacySemVerPadded":"1.2.3-unstable0004",
"AssemblySemVer":"1.2.3.0",
"FullSemVer":"1.2.3-unstable.4+5",
"InformationalVersion":"1.2.3-unstable.4+5.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0004",
"NuGetVersion":"1.2.3-unstable0004"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Major":1,
"Minor":2,
"Patch":3,
"PreReleaseTag":"",
"PreReleaseTagWithDash":"",
"BuildMetaData":5,
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",
"MajorMinorPatch":"1.2.3",
"SemVer":"1.2.3",
"LegacySemVer":"1.2.3",
"LegacySemVerPadded":"1.2.3",
"AssemblySemVer":"1.2.3.0",
"FullSemVer":"1.2.3+5",
"InformationalVersion":"1.2.3+5.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3",
"NuGetVersion":"1.2.3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Major":1,
"Minor":2,
"Patch":3,
"PreReleaseTag":"unstable.5",
"PreReleaseTagWithDash":"-unstable.5",
"BuildMetaData":5,
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",
"MajorMinorPatch":"1.2.3",
"SemVer":"1.2.3-unstable.5",
"LegacySemVer":"1.2.3-unstable5",
"LegacySemVerPadded":"1.2.3-unstable0005",
"AssemblySemVer":"1.2.3.0",
"FullSemVer":"1.2.3-unstable.5+4",
"InformationalVersion":"1.2.3-unstable.5+4.Branch.develop.Sha.commitSha",
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3-unstable0005",
"NuGetVersion":"1.2.3-unstable0005"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Major":1,
"Minor":2,
"Patch":3,
"PreReleaseTag":"",
"PreReleaseTagWithDash":"",
"BuildMetaData":5,
"FullBuildMetaData":"5.Branch.develop.Sha.commitSha",
"MajorMinorPatch":"1.2.3",
"SemVer":"1.2.3.5",
"LegacySemVer":"1.2.3.5",
"LegacySemVerPadded":"1.2.3.5",
"AssemblySemVer":"1.2.3.0",
"FullSemVer":"1.2.3.5",
"InformationalVersion":"1.2.3.5+Branch.develop.Sha.commitSha",
"BranchName":"develop",
"Sha":"commitSha",
"NuGetVersionV2":"1.2.3.5",
"NuGetVersion":"1.2.3.5"
}
62 changes: 59 additions & 3 deletions GitVersionCore.Tests/VariableProviderTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using ApprovalTests;
using GitVersion;
using NUnit.Framework;
using Shouldly;

[TestFixture]
public class VariableProviderTests
{
[Test]
public void DevelopBranchFormatsSemVerForCiFeed()
public void ProvidesVariablesInContinuousDeliveryModeForPreRelease()
{
var semVer = new SemanticVersion
{
Expand All @@ -21,10 +21,66 @@ public void DevelopBranchFormatsSemVerForCiFeed()
semVer.BuildMetaData.Sha = "commitSha";
semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDelivery);

Approvals.Verify(JsonOutputFormatter.ToJson(vars));
}

[Test]
public void ProvidesVariablesInContinuousDeploymentModeForPreRelease()
{
var semVer = new SemanticVersion
{
Major = 1,
Minor = 2,
Patch = 3,
PreReleaseTag = "unstable.4",
BuildMetaData = "5.Branch.develop"
};

semVer.BuildMetaData.Sha = "commitSha";
semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDeployment);

Approvals.Verify(JsonOutputFormatter.ToJson(vars));
}

[Test]
public void ProvidesVariablesInContinuousDeliveryModeForStable()
{
var semVer = new SemanticVersion
{
Major = 1,
Minor = 2,
Patch = 3,
BuildMetaData = "5.Branch.develop"
};

semVer.BuildMetaData.Sha = "commitSha";
semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDelivery);

vars[VariableProvider.SemVer].ShouldBe("1.2.3.5-unstable");
Approvals.Verify(JsonOutputFormatter.ToJson(vars));
}

[Test]
public void ProvidesVariablesInContinuousDeploymentModeForStable()
{
var semVer = new SemanticVersion
{
Major = 1,
Minor = 2,
Patch = 3,
BuildMetaData = "5.Branch.develop"
};

semVer.BuildMetaData.Sha = "commitSha";
semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");

var vars = VariableProvider.GetVariablesFor(semVer, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDeployment);

Approvals.Verify(JsonOutputFormatter.ToJson(vars));
}
}
17 changes: 0 additions & 17 deletions GitVersionCore/AssemblyVersionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ public static class AssemblyVersionsGenerator
}

}
public static string GetAssemblyFileVersion(
this SemanticVersion sv,
AssemblyVersioningScheme scheme)
{
switch (scheme)
{
case AssemblyVersioningScheme.Major:
case AssemblyVersioningScheme.MajorMinor:
case AssemblyVersioningScheme.MajorMinorPatch:
return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch);
case AssemblyVersioningScheme.MajorMinorPatchMetadata:
return string.Format("{0}.{1}.{2}.{3}", sv.Major, sv.Minor, sv.Patch, sv.BuildMetaData.CommitsSinceTag ?? 0);
default:
throw new ArgumentException(string.Format("Unexpected value ({0}).", scheme), "scheme");
}

}

}
}
2 changes: 1 addition & 1 deletion GitVersionCore/BuildServers/AppVeyor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override string GenerateSetVersionMessage(string versionToUseForBuildNumb
{
if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.NoContent)
{
var message = String.Format("Request failed. Received HTTP {0}", response.StatusCode);
var message = string.Format("Request failed. Received HTTP {0}", response.StatusCode);
return message;
}
}
Expand Down
11 changes: 2 additions & 9 deletions GitVersionCore/BuildServers/BuildServerBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace GitVersion
{
using System;
using System.Collections.Generic;

public abstract class BuildServerBase : IBuildServer
{
Expand All @@ -10,21 +9,15 @@ public abstract class BuildServerBase : IBuildServer
public abstract string GenerateSetVersionMessage(string versionToUseForBuildNumber);
public abstract string[] GenerateSetParameterMessage(string name, string value);

public virtual void WriteIntegration(SemanticVersion semanticVersion, Action<string> writer, Dictionary<string, string> variables)
public virtual void WriteIntegration(Action<string> writer, VersionVariables variables)
{
if (semanticVersion == null)
{
return;
}

if (writer == null)
{
return;
}

writer(string.Format("Executing GenerateSetVersionMessage for '{0}'.", GetType().Name));
// TODO This should come from variable provider
writer(GenerateSetVersionMessage(semanticVersion.ToString("f")));
writer(GenerateSetVersionMessage(variables.FullSemVer));
writer(string.Format("Executing GenerateBuildLogOutput for '{0}'.", GetType().Name));
foreach (var buildParameter in BuildOutputFormatter.GenerateBuildLogOutput(this, variables))
{
Expand Down
3 changes: 1 addition & 2 deletions GitVersionCore/BuildServers/IBuildServer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace GitVersion
{
using System;
using System.Collections.Generic;

public interface IBuildServer
{
Expand All @@ -10,7 +9,7 @@ public interface IBuildServer
string GenerateSetVersionMessage(string versionToUseForBuildNumber);
string[] GenerateSetParameterMessage(string name, string value);

void WriteIntegration(SemanticVersion semanticVersion, Action<string> writer, Dictionary<string,string> variables);
void WriteIntegration(Action<string> writer, VersionVariables variables);
}

}
3 changes: 2 additions & 1 deletion GitVersionCore/GitVersionCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
<Compile Include="Helpers\IFileSystem.cs" />
<Compile Include="Helpers\ProcessHelper.cs" />
<Compile Include="LastMinorVersionFinder.cs" />
<Compile Include="OutputVariables\CommitsAsFourthVersionPartFormatter.cs" />
<Compile Include="OutputVariables\VersionVariables.cs" />
<Compile Include="SemanticVersionExtensions.cs" />
<Compile Include="VersioningModes\ContinuousDeliveryMode.cs" />
<Compile Include="VersioningModes\ContinuousDeploymentMode.cs" />
Expand Down Expand Up @@ -123,7 +125,6 @@
<Compile Include="OutputFormatters\BuildOutputFormatter.cs" />
<Compile Include="OutputFormatters\JsonOutputFormatter.cs" />
<Compile Include="OutputType.cs" />
<Compile Include="OutputVariables\CiFeedFormatter.cs" />
<Compile Include="OutputVariables\VariableProvider.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="RepositoryLoader.cs" />
Expand Down
2 changes: 1 addition & 1 deletion GitVersionCore/OutputFormatters/BuildOutputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public static class BuildOutputFormatter
{
public static IEnumerable<string> GenerateBuildLogOutput(IBuildServer buildServer, Dictionary<string, string> variables)
public static IEnumerable<string> GenerateBuildLogOutput(IBuildServer buildServer, VersionVariables variables)
{
var output = new List<string>();

Expand Down
3 changes: 1 addition & 2 deletions GitVersionCore/OutputFormatters/JsonOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
namespace GitVersion
{
using System.Collections.Generic;
using System.Linq;
using System.Text;

public static class JsonOutputFormatter
{
public static string ToJson(Dictionary<string, string> variables)
public static string ToJson(VersionVariables variables)
{
var builder = new StringBuilder();
builder.AppendLine("{");
Expand Down
33 changes: 0 additions & 33 deletions GitVersionCore/OutputVariables/CiFeedFormatter.cs

This file was deleted.