Skip to content

Commit

Permalink
Removing Contract.Assume
Browse files Browse the repository at this point in the history
  • Loading branch information
HHobeck committed Feb 19, 2024
1 parent 8119ea1 commit 4664ed9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
3 changes: 0 additions & 3 deletions src/GitVersion.Core/Git/ReferenceName.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Text.RegularExpressions;
using GitVersion.Extensions;
using GitVersion.Helpers;
Expand Down Expand Up @@ -85,8 +84,6 @@ public bool TryGetSemanticVersion([NotNullWhen(true)] out (SemanticVersion Value
{
result = default;

Contract.Assume(versionPatternRegex.ToString().StartsWith('^'));

int length = 0;
foreach (var branchPart in WithoutOrigin.Split(GetBranchSeparator()))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics.Contracts;
using GitVersion.Common;
using GitVersion.Logging;

Expand All @@ -23,20 +22,17 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV

private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
{
Contract.Assume(semanticVersion.PreReleaseTag.Number.HasValue);

var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);

return new SemanticVersion(semanticVersion)
{
PreReleaseTag = new SemanticVersionPreReleaseTag(semanticVersion.PreReleaseTag)
{
Number = semanticVersion.PreReleaseTag.Number.Value + buildMetaData.CommitsSinceTag - 1
Number = semanticVersion.PreReleaseTag.Number!.Value + buildMetaData.CommitsSinceTag - 1
},
BuildMetaData = new SemanticVersionBuildMetaData(buildMetaData)
{
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag.Value,
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag!.Value,
CommitsSinceTag = null
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics.Contracts;
using GitVersion.Common;
using GitVersion.Logging;

Expand All @@ -18,14 +17,13 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV
private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
{
var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);

return new SemanticVersion(semanticVersion)
{
PreReleaseTag = SemanticVersionPreReleaseTag.Empty,
BuildMetaData = new SemanticVersionBuildMetaData(buildMetaData)
{
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag.Value,
CommitsSinceVersionSource = buildMetaData.CommitsSinceTag!.Value,
CommitsSinceTag = null
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Diagnostics.Contracts;
using GitVersion.Common;
using GitVersion.Logging;

Expand All @@ -18,7 +17,6 @@ public SemanticVersion Calculate(SemanticVersion semanticVersion, ICommit? baseV
private SemanticVersion CalculateInternal(SemanticVersion semanticVersion, ICommit? baseVersionSource)
{
var buildMetaData = CreateVersionBuildMetaData(baseVersionSource);
Contract.Assume(buildMetaData.CommitsSinceTag.HasValue);

return new SemanticVersion(semanticVersion)
{
Expand Down

0 comments on commit 4664ed9

Please sign in to comment.