Skip to content

Commit 11c426d

Browse files
authored
Normalize version numbers in VersionBumper (#28820)
1 parent c38db06 commit 11c426d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/VersionController/Models/VersionBumper.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,17 @@ private string GetBumpedVersion()
238238
string warningMsg = $"The GA version of {moduleName} in gallery ({maxGAedVersionInGallery}) is greater or equal to the bumped version({bumpedVersion}). Continue bumping version for {moduleName}.";
239239
_logger.LogWarning(warningMsg);
240240
bumpedVersion = GetBumpedVersionByType(bumpedVersion, versionBump);
241+
// Normalize version numbers if they exceed or equal 1000. Add this to avoid infinite loop when patch version is bumped but actually the minor version is less than maxGAedVersionInGallery.minor.
242+
if (bumpedVersion.Patch >= 1000)
243+
{
244+
bumpedVersion = new AzurePSVersion(bumpedVersion.Major, bumpedVersion.Minor + 1, bumpedVersion.Patch - 1000, bumpedVersion.Label);
245+
_logger.LogWarning($"Patch version exceeded 999. Normalized version to {bumpedVersion}");
246+
}
247+
if (bumpedVersion.Minor >= 1000)
248+
{
249+
bumpedVersion = new AzurePSVersion(bumpedVersion.Major + 1, bumpedVersion.Minor - 1000, bumpedVersion.Patch, bumpedVersion.Label);
250+
_logger.LogWarning($"Minor version exceeded 999. Normalized version to {bumpedVersion}");
251+
}
241252
}
242253

243254
// Continue bumping version until bumpedVersion is higher than maxPreGAedVersionInGallery in same major version

0 commit comments

Comments
 (0)