Skip to content

Commit 1444497

Browse files
authored
Fix for validation error when new sprint occurs. (#20711)
Erro message that was present: Updates needed: ... D:\a\_work\1\s\globalversion.txt (overwrite=true). Dest file doesn't match source. System.Exception: Updates needed, please run node make.js ...
1 parent 298ee40 commit 1444497

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

BuildConfigGen/Program.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
170170
tasks = allTasksList.Where(s => taskList.Where(tl => string.Equals(tl, s.Key, StringComparison.OrdinalIgnoreCase)).Any());
171171
}
172172

173+
bool globalVersionBump = false;
174+
173175
if (includeLocalPackagesBuildConfig)
174176
{
175177
Console.WriteLine("Updating global version...");
@@ -204,7 +206,10 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
204206
bool anyTaskVersionUpdated = taskVersionInfo.Values.Any(x => x.versionsUpdated.Any());
205207
bool noCurrentGlobalVersion = globalVersion is null;
206208
bool maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch = globalVersion is not null && maxPatchForCurrentSprint >= globalVersion.Patch;
207-
if (anyTaskVersionUpdated || noCurrentGlobalVersion || maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch)
209+
210+
globalVersionBump = anyTaskVersionUpdated || noCurrentGlobalVersion || maxPatchForCurrentSprintGreaterOrEqualToGlobalPatch;
211+
212+
if (globalVersionBump)
208213
{
209214
maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1;
210215

@@ -239,16 +244,19 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
239244
}
240245
else
241246
{
242-
if (globalVersion.Minor == currentSprint)
243-
{
244-
globalVersion = globalVersion.CloneWithMinorAndPatch(currentSprint, Math.Max(maxPatchForCurrentSprint, globalVersion.Patch));
245-
globalVersion = globalVersion.CloneWithMajor(taskMajorVersion);
246-
}
247-
else
247+
if (globalVersionBump)
248248
{
249-
// this could fail if there is a task with a future-sprint version, which should not be the case. If that happens, CheckForDuplicates will throw
250-
globalVersion = globalVersion.CloneWithMinorAndPatch(currentSprint, 0);
251-
globalVersion = globalVersion.CloneWithMajor(taskMajorVersion);
249+
if (globalVersion.Minor == currentSprint)
250+
{
251+
globalVersion = globalVersion.CloneWithMinorAndPatch(currentSprint, Math.Max(maxPatchForCurrentSprint, globalVersion.Patch));
252+
globalVersion = globalVersion.CloneWithMajor(taskMajorVersion);
253+
}
254+
else
255+
{
256+
// this could fail if there is a task with a future-sprint version, which should not be the case. If that happens, CheckForDuplicates will throw
257+
globalVersion = globalVersion.CloneWithMinorAndPatch(currentSprint, 0);
258+
globalVersion = globalVersion.CloneWithMajor(taskMajorVersion);
259+
}
252260
}
253261
}
254262
}

0 commit comments

Comments
 (0)