Skip to content

Change Int32 to Int64 #3028

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

Merged
merged 1 commit into from
Mar 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public class SemanticVersionTests : TestBase
[TestCase("version-1.2.3", 1, 2, 3, null, null, null, null, null, null, "1.2.3", "version-")]
[TestCase("1", 1, 0, 0, null, null, null, null, null, null, "1.0.0", null)]
[TestCase("1.1", 1, 1, 0, null, null, null, null, null, null, "1.1.0", null)]
[TestCase("1.0.0-develop-20201007113711", 1, 0, 0, "develop-20201007113711", null, null, null, null, null, "1.0.0-develop-20201007113711", null)]
[TestCase("20201007113711.658165168461351.64136516984163213-develop-20201007113711.98848747823+65416321321", 20201007113711, 658165168461351, 64136516984163213, "develop-20201007113711", 98848747823, 65416321321, null, null, null, "20201007113711.658165168461351.64136516984163213-develop-20201007113711.98848747823+65416321321", null)]
public void ValidateVersionParsing(
string versionString, int major, int minor, int patch, string tag, int? tagNumber, int? numberOfBuilds,
string versionString, long major, long minor, long patch, string tag, long? tagNumber, long? numberOfBuilds,
string branchName, string sha, string otherMetaData, string fullFormattedVersionString, string tagPrefixRegex)
{
fullFormattedVersionString ??= versionString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void UpdatePreReleaseTag(SemanticVersion semanticVersion, string? branch
{
var tagToUse = context.Configuration?.GetBranchSpecificTag(this.log, context.CurrentBranch?.Name.Friendly, branchNameOverride);

int? number = null;
long? number = null;

var lastTag = this.repositoryStore
.GetVersionTagsOnBranch(context.CurrentBranch!, context.Configuration?.GitTagPrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public class SemanticVersion : IFormattable, IComparable<SemanticVersion>, IEqua
@"^(?<SemVer>(?<Major>\d+)(\.(?<Minor>\d+))?(\.(?<Patch>\d+))?)(\.(?<FourthPart>\d+))?(-(?<Tag>[^\+]*))?(\+(?<BuildMetaData>.*))?$",
RegexOptions.Compiled);

public int Major;
public int Minor;
public int Patch;
public long Major;
public long Minor;
public long Patch;
public SemanticVersionPreReleaseTag? PreReleaseTag;
public SemanticVersionBuildMetaData? BuildMetaData;

public SemanticVersion(int major = 0, int minor = 0, int patch = 0)
public SemanticVersion(long major = 0, long minor = 0, long patch = 0)
{
this.Major = major;
this.Minor = minor;
Expand Down Expand Up @@ -74,9 +74,9 @@ public override int GetHashCode()
{
unchecked
{
var hashCode = this.Major;
hashCode = (hashCode * 397) ^ this.Minor;
hashCode = (hashCode * 397) ^ this.Patch;
var hashCode = this.Major.GetHashCode();
hashCode = (hashCode * 397) ^ this.Minor.GetHashCode();
hashCode = (hashCode * 397) ^ this.Patch.GetHashCode();
hashCode = (hashCode * 397) ^ (this.PreReleaseTag != null ? this.PreReleaseTag.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.BuildMetaData != null ? this.BuildMetaData.GetHashCode() : 0);
return hashCode;
Expand Down Expand Up @@ -168,9 +168,9 @@ public static bool TryParse(string version, string? tagPrefixRegex, [NotNullWhen

semanticVersion = new SemanticVersion
{
Major = int.Parse(parsed.Groups["Major"].Value),
Minor = parsed.Groups["Minor"].Success ? int.Parse(parsed.Groups["Minor"].Value) : 0,
Patch = parsed.Groups["Patch"].Success ? int.Parse(parsed.Groups["Patch"].Value) : 0,
Major = long.Parse(parsed.Groups["Major"].Value),
Minor = parsed.Groups["Minor"].Success ? long.Parse(parsed.Groups["Minor"].Value) : 0,
Patch = parsed.Groups["Patch"].Success ? long.Parse(parsed.Groups["Patch"].Value) : 0,
PreReleaseTag = SemanticVersionPreReleaseTag.Parse(parsed.Groups["Tag"].Value),
BuildMetaData = semanticVersionBuildMetaData
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public class SemanticVersionBuildMetaData : IFormattable, IEquatable<SemanticVer
private static readonly LambdaEqualityHelper<SemanticVersionBuildMetaData> EqualityHelper =
new(x => x.CommitsSinceTag, x => x.Branch, x => x.Sha);

public int? CommitsSinceTag;
public long? CommitsSinceTag;
public string? Branch;
public string? Sha;
public string? ShortSha;
public string? OtherMetaData;
public DateTimeOffset? CommitDate;
public string? VersionSourceSha;
public int? CommitsSinceVersionSource;
public int UncommittedChanges;
public long? CommitsSinceVersionSource;
public long UncommittedChanges;

public SemanticVersionBuildMetaData()
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public static SemanticVersionBuildMetaData Parse(string? buildMetaData)

if (parsed.Groups["BuildNumber"].Success)
{
semanticVersionBuildMetaData.CommitsSinceTag = int.Parse(parsed.Groups["BuildNumber"].Value);
semanticVersionBuildMetaData.CommitsSinceTag = long.Parse(parsed.Groups["BuildNumber"].Value);
semanticVersionBuildMetaData.CommitsSinceVersionSource = semanticVersionBuildMetaData.CommitsSinceTag ?? 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public SemanticVersionPreReleaseTag()
{
}

public SemanticVersionPreReleaseTag(string? name, int? number)
public SemanticVersionPreReleaseTag(string? name, long? number)
{
Name = name;
Number = number;
Expand All @@ -29,7 +29,7 @@ public SemanticVersionPreReleaseTag(SemanticVersionPreReleaseTag? preReleaseTag)
}

public string? Name { get; set; }
public int? Number { get; set; }
public long? Number { get; set; }
public bool? PromotedFromCommits { get; set; }

public override bool Equals(object? obj) => Equals(obj as SemanticVersionPreReleaseTag);
Expand Down Expand Up @@ -76,7 +76,7 @@ public static SemanticVersionPreReleaseTag Parse(string? preReleaseTag)
}

var value = match.Groups["name"].Value;
var number = match.Groups["number"].Success ? int.Parse(match.Groups["number"].Value) : (int?)null;
var number = match.Groups["number"].Success ? long.Parse(match.Groups["number"].Value) : (long?)null;
if (value.EndsWith("-"))
return new SemanticVersionPreReleaseTag(preReleaseTag, null);

Expand Down