@@ -109,7 +109,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
109
109
}
110
110
111
111
string currentDir = Environment . CurrentDirectory ;
112
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
112
+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
113
113
114
114
string globalVersionPath = Path . Combine ( gitRootPath , @"globalversion.txt" ) ;
115
115
TaskVersion ? globalVersion = GetGlobalVersion ( gitRootPath , globalVersionPath ) ;
@@ -208,7 +208,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
208
208
Console . WriteLine ( $ "Global version: maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1") ;
209
209
}
210
210
211
- Console . WriteLine ( $ "Global version update: globalVersion = { globalVersion } maxPatchForCurrentSprint={ maxPatchForCurrentSprint } " ) ;
211
+ Console . WriteLine ( $ "Global version update: globalVersion = { globalVersion } maxPatchForCurrentSprint={ maxPatchForCurrentSprint } ") ;
212
212
}
213
213
else
214
214
{
@@ -249,6 +249,14 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
249
249
}
250
250
}
251
251
}
252
+ else
253
+ {
254
+ // if we're not updating local packages, we need to ensure the global version is updated to the task major version. existing patch number is preserved
255
+ if ( globalVersion is not null )
256
+ {
257
+ globalVersion = globalVersion . CloneWithMajor ( taskMajorVersion ) ;
258
+ }
259
+ }
252
260
253
261
if ( globalVersion is not null )
254
262
{
@@ -265,7 +273,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
265
273
ensureUpdateModeVerifier ! . WriteAllText ( globalVersionPath , globalVersion ! . MinorPatchToString ( ) , false ) ;
266
274
}
267
275
268
- ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( "(global)" , skipContentCheck : false ) ;
276
+ ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( null , skipContentCheck : false ) ;
269
277
270
278
foreach ( var t in tasks )
271
279
{
@@ -284,6 +292,37 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
284
292
}
285
293
}
286
294
295
+ private static string GetTasksRootPath ( string inputCurrentDir )
296
+ {
297
+ string ? currentDir = inputCurrentDir ;
298
+ string ? tasksRootPath = null ;
299
+
300
+ do
301
+ {
302
+ string currentDirGit = Path . Combine ( currentDir , ".git" ) ;
303
+
304
+ if ( Directory . Exists ( currentDirGit ) )
305
+ {
306
+ tasksRootPath = currentDir ;
307
+ }
308
+
309
+ currentDir = ( new DirectoryInfo ( currentDir ) ) . Parent ? . FullName ;
310
+
311
+ } while ( currentDir != null ) ;
312
+
313
+ if ( tasksRootPath == null )
314
+ {
315
+ throw new Exception ( $ "could not find .git in { currentDir } ") ;
316
+ }
317
+
318
+ if ( ! File . Exists ( Path . Combine ( tasksRootPath , "make-options.json" ) ) )
319
+ {
320
+ throw new Exception ( $ "make-options.json not found in tasksRootPath={ tasksRootPath } ") ;
321
+ }
322
+
323
+ return tasksRootPath ;
324
+ }
325
+
287
326
private static IEnumerable < string > FilterConfigsForTask ( string ? configs , KeyValuePair < string , MakeOptionsReader . AgentTask > t )
288
327
{
289
328
var configsList = t . Value . Configs . AsEnumerable ( ) ;
@@ -343,7 +382,7 @@ private static void GetVersions(string task, string configsString, out List<(str
343
382
344
383
string currentDir = Environment . CurrentDirectory ;
345
384
346
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
385
+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
347
386
348
387
string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
349
388
if ( ! Directory . Exists ( taskTargetPath ) )
@@ -419,7 +458,7 @@ private static int GetCurrentSprint()
419
458
return currentSprint ;
420
459
}
421
460
422
- private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( string task , bool skipContentCheck )
461
+ private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( string ? task , bool skipContentCheck )
423
462
{
424
463
// if !writeUpdates, error if we have written any updates
425
464
var verifyErrors = ensureUpdateModeVerifier ! . GetVerifyErrors ( skipContentCheck ) . ToList ( ) ;
@@ -433,7 +472,14 @@ private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferEr
433
472
Console . WriteLine ( s ) ;
434
473
}
435
474
436
- throw new Exception ( $ "Updates needed, please run npm make.js --task { task } ") ;
475
+ if ( task is null )
476
+ {
477
+ throw new Exception ( $ "Updates needed, please run node make.js") ;
478
+ }
479
+ else
480
+ {
481
+ throw new Exception ( $ "Updates needed, please run node make.js --task { task } ") ;
482
+ }
437
483
}
438
484
}
439
485
@@ -459,8 +505,8 @@ private static void MainUpdateTask(
459
505
try
460
506
{
461
507
string currentDir = Environment . CurrentDirectory ;
462
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
463
- string versionMapFile = GetVersionMapFile ( task , gitRootPath , generatedFolder ) ;
508
+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
509
+ string versionMapFile = GetVersionMapFile ( task , generatedFolder ) ;
464
510
465
511
string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
466
512
if ( ! Directory . Exists ( taskTargetPath ) )
@@ -489,7 +535,11 @@ private static void MainUpdateTask(
489
535
490
536
foreach ( var config in targetConfigs )
491
537
{
492
- if ( config . useGlobalVersion && ! hasGlobalVersion )
538
+ if ( config . useGlobalVersion && ! includeLocalPackagesBuildConfig )
539
+ {
540
+ Console . WriteLine ( $ "Info: MainUpdateTask: Skipping useGlobalVersion config for task b/c --include-local-packages-build-config. not specified. hasGlobalVersion={ hasGlobalVersion } config.useGlobalVersion={ config . useGlobalVersion } includeLocalPackagesBuildConfig={ includeLocalPackagesBuildConfig } ") ;
541
+ }
542
+ else if ( config . useGlobalVersion && ! hasGlobalVersion )
493
543
{
494
544
Console . WriteLine ( $ "Info: MainUpdateTask: Skipping useGlobalVersion config for task b/c GlobalVersion not initialized. (to opt-in and start producing LocalBuildConfig, run with --include-local-packages-build-config. hasGlobalVersion={ hasGlobalVersion } config.useGlobalVersion={ config . useGlobalVersion } ). Note: this is not an error!") ;
495
545
}
@@ -608,7 +658,7 @@ private static void MainUpdateTask(
608
658
}
609
659
}
610
660
611
- private static string GetVersionMapFile ( string task , string gitRootPath , string generatedFolder )
661
+ private static string GetVersionMapFile ( string task , string generatedFolder )
612
662
{
613
663
return Path . Combine ( generatedFolder , @$ "{ task } .versionmap.txt") ;
614
664
}
@@ -1078,7 +1128,7 @@ private static void CopyConfig(string gitRootPath, string taskTargetPathOrUnders
1078
1128
private static void UpdateVersionsForTask ( string task , TaskStateStruct taskState , HashSet < Config . ConfigRecord > targetConfigs , int currentSprint , string globalVersionPath , TaskVersion ? globalVersion , string generatedFolder )
1079
1129
{
1080
1130
string currentDir = Environment . CurrentDirectory ;
1081
- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
1131
+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
1082
1132
string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
1083
1133
1084
1134
if ( ! Directory . Exists ( taskTargetPath ) )
@@ -1093,7 +1143,7 @@ private static void UpdateVersionsForTask(string task, TaskStateStruct taskState
1093
1143
1094
1144
bool defaultVersionMatchesSourceVersion ;
1095
1145
1096
- string versionMapFile = GetVersionMapFile ( task , gitRootPath , generatedFolder ) ;
1146
+ string versionMapFile = GetVersionMapFile ( task , generatedFolder ) ;
1097
1147
1098
1148
{
1099
1149
TaskVersion ? defaultVersion = null ;
0 commit comments