-
Notifications
You must be signed in to change notification settings - Fork 653
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
Add support and tests for AssemblyInformationalVersion configurability #660
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Web" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is needed from this reference. Am worried this could cause issues porting to .net core/mono which is happening in v4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will verify and report back. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StringFormatWith.cs needs them for the DataBinder class which can throw HttpException. This is using the code you recommended to do the formatting, which definitely works well. Another option might be to use C#6 string format inlining e.g. $"{foo} {bar}" instead of string.Format("{0} {1}", foo, bar). But i wasn't sure you wanted to require C#6 semantics for the code to compile. try |
||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
|
@@ -117,6 +118,8 @@ | |
<Compile Include="OutputVariables\VersionVariables.cs" /> | ||
<Compile Include="Extensions\ExtensionMethods.git.cs" /> | ||
<Compile Include="SemanticVersionExtensions.cs" /> | ||
<Compile Include="SemanticVersionFormatValues.cs" /> | ||
<Compile Include="StringFormatWith.cs" /> | ||
<Compile Include="VersionCalculation\BaseVersionCalculator.cs" /> | ||
<Compile Include="VersionCalculation\BaseVersionCalculators\BaseVersion.cs" /> | ||
<Compile Include="VersionCalculation\BaseVersionCalculators\ConfigNextVersionBaseVersionStrategy.cs" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
namespace GitVersion | ||
{ | ||
public class SemanticVersionFormatValues | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this class in order to generate the VersionVariables class since the types we're using int he formatting need to come from a constructed object. And if we exposed the VersionVariables object as what's valid for formatting, then someone could do {InformationalVersion} and get themselves into an infinite loop. So this gives us type safety of what's allowed to be formatted as well as getting the formatting done to construct the VersionVariables type. I agree it's redundant on most fields (since VersionVariables now just becomes a passthrough/holder for most of the values calculated in the SemanticVersionFormatValues class. Open to suggestions to minimize here if you have them. |
||
{ | ||
readonly SemanticVersion _semver; | ||
readonly EffectiveConfiguration _config; | ||
|
||
public SemanticVersionFormatValues(SemanticVersion semver, EffectiveConfiguration config) | ||
{ | ||
_semver = semver; | ||
_config = config; | ||
} | ||
|
||
public string Major | ||
{ | ||
get { return _semver.Major.ToString(); } | ||
} | ||
|
||
public string Minor | ||
{ | ||
get { return _semver.Minor.ToString(); } | ||
} | ||
|
||
public string Patch | ||
{ | ||
get { return _semver.Patch.ToString(); } | ||
} | ||
|
||
public string PreReleaseTag | ||
{ | ||
get { return _semver.PreReleaseTag; } | ||
} | ||
|
||
public string PreReleaseTagWithDash | ||
{ | ||
get { return _semver.PreReleaseTag.HasTag() ? "-" + _semver.PreReleaseTag : null; } | ||
} | ||
|
||
public string BuildMetaData | ||
{ | ||
get { return _semver.BuildMetaData; } | ||
} | ||
|
||
public string BuildMetaDataPadded | ||
{ | ||
get { return _semver.BuildMetaData.ToString("p" + _config.BuildMetaDataPadding); } | ||
} | ||
|
||
public string FullBuildMetaData | ||
{ | ||
get { return _semver.BuildMetaData.ToString("f"); } | ||
} | ||
|
||
public string MajorMinorPatch | ||
{ | ||
get { return string.Format("{0}.{1}.{2}", _semver.Major, _semver.Minor, _semver.Patch); } | ||
} | ||
|
||
public string SemVer | ||
{ | ||
get { return _semver.ToString(); } | ||
} | ||
|
||
public string LegacySemVer | ||
{ | ||
get { return _semver.ToString("l"); } | ||
} | ||
|
||
public string LegacySemVerPadded | ||
{ | ||
get { return _semver.ToString("lp" + _config.LegacySemVerPadding); } | ||
} | ||
|
||
public string AssemblySemVer | ||
{ | ||
get { return _semver.GetAssemblyVersion(_config.AssemblyVersioningScheme); } | ||
} | ||
|
||
public string FullSemVer | ||
{ | ||
get { return _semver.ToString("f"); } | ||
} | ||
|
||
public string BranchName | ||
{ | ||
get { return _semver.BuildMetaData.Branch; } | ||
} | ||
|
||
public string Sha | ||
{ | ||
get { return _semver.BuildMetaData.Sha; } | ||
} | ||
|
||
public string CommitDate | ||
{ | ||
get { return _semver.BuildMetaData.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"); } | ||
} | ||
|
||
// TODO When NuGet 3 is released: public string NuGetVersionV3 { get { return ??; } } | ||
|
||
public string NuGetVersionV2 | ||
{ | ||
get { return LegacySemVerPadded.ToLower(); } | ||
} | ||
|
||
public string NuGetVersion | ||
{ | ||
get { return NuGetVersionV2; } | ||
} | ||
|
||
public string DefaultInformationalVersion | ||
{ | ||
get { return _semver.ToString("i"); } | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also like to see a test which uses multiple format values. i.e
'{Major}.{Minor}.{Patch}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.