@@ -109,7 +109,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
109109 }
110110
111111 string currentDir = Environment . CurrentDirectory ;
112- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
112+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
113113
114114 string globalVersionPath = Path . Combine ( gitRootPath , @"globalversion.txt" ) ;
115115 TaskVersion ? globalVersion = GetGlobalVersion ( gitRootPath , globalVersionPath ) ;
@@ -208,7 +208,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
208208 Console . WriteLine ( $ "Global version: maxPatchForCurrentSprint = maxPatchForCurrentSprint + 1") ;
209209 }
210210
211- Console . WriteLine ( $ "Global version update: globalVersion = { globalVersion } maxPatchForCurrentSprint={ maxPatchForCurrentSprint } " ) ;
211+ Console . WriteLine ( $ "Global version update: globalVersion = { globalVersion } maxPatchForCurrentSprint={ maxPatchForCurrentSprint } ") ;
212212 }
213213 else
214214 {
@@ -249,6 +249,14 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
249249 }
250250 }
251251 }
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+ }
252260
253261 if ( globalVersion is not null )
254262 {
@@ -265,7 +273,7 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
265273 ensureUpdateModeVerifier ! . WriteAllText ( globalVersionPath , globalVersion ! . MinorPatchToString ( ) , false ) ;
266274 }
267275
268- ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( "(global)" , skipContentCheck : false ) ;
276+ ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( null , skipContentCheck : false ) ;
269277
270278 foreach ( var t in tasks )
271279 {
@@ -284,6 +292,37 @@ private static void MainInner(string? task, string? configs, int? currentSprintN
284292 }
285293 }
286294
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+
287326 private static IEnumerable < string > FilterConfigsForTask ( string ? configs , KeyValuePair < string , MakeOptionsReader . AgentTask > t )
288327 {
289328 var configsList = t . Value . Configs . AsEnumerable ( ) ;
@@ -343,7 +382,7 @@ private static void GetVersions(string task, string configsString, out List<(str
343382
344383 string currentDir = Environment . CurrentDirectory ;
345384
346- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
385+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
347386
348387 string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
349388 if ( ! Directory . Exists ( taskTargetPath ) )
@@ -419,7 +458,7 @@ private static int GetCurrentSprint()
419458 return currentSprint ;
420459 }
421460
422- private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( string task , bool skipContentCheck )
461+ private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferError ( string ? task , bool skipContentCheck )
423462 {
424463 // if !writeUpdates, error if we have written any updates
425464 var verifyErrors = ensureUpdateModeVerifier ! . GetVerifyErrors ( skipContentCheck ) . ToList ( ) ;
@@ -433,7 +472,14 @@ private static void ThrowWithUserFriendlyErrorToRerunWithWriteUpdatesIfVeriferEr
433472 Console . WriteLine ( s ) ;
434473 }
435474
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+ }
437483 }
438484 }
439485
@@ -459,8 +505,8 @@ private static void MainUpdateTask(
459505 try
460506 {
461507 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 ) ;
464510
465511 string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
466512 if ( ! Directory . Exists ( taskTargetPath ) )
@@ -489,7 +535,11 @@ private static void MainUpdateTask(
489535
490536 foreach ( var config in targetConfigs )
491537 {
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 )
493543 {
494544 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!") ;
495545 }
@@ -608,7 +658,7 @@ private static void MainUpdateTask(
608658 }
609659 }
610660
611- private static string GetVersionMapFile ( string task , string gitRootPath , string generatedFolder )
661+ private static string GetVersionMapFile ( string task , string generatedFolder )
612662 {
613663 return Path . Combine ( generatedFolder , @$ "{ task } .versionmap.txt") ;
614664 }
@@ -1078,7 +1128,7 @@ private static void CopyConfig(string gitRootPath, string taskTargetPathOrUnders
10781128 private static void UpdateVersionsForTask ( string task , TaskStateStruct taskState , HashSet < Config . ConfigRecord > targetConfigs , int currentSprint , string globalVersionPath , TaskVersion ? globalVersion , string generatedFolder )
10791129 {
10801130 string currentDir = Environment . CurrentDirectory ;
1081- string gitRootPath = GitUtil . GetGitRootPath ( currentDir ) ;
1131+ string gitRootPath = GetTasksRootPath ( currentDir ) ;
10821132 string taskTargetPath = Path . Combine ( gitRootPath , "Tasks" , task ) ;
10831133
10841134 if ( ! Directory . Exists ( taskTargetPath ) )
@@ -1093,7 +1143,7 @@ private static void UpdateVersionsForTask(string task, TaskStateStruct taskState
10931143
10941144 bool defaultVersionMatchesSourceVersion ;
10951145
1096- string versionMapFile = GetVersionMapFile ( task , gitRootPath , generatedFolder ) ;
1146+ string versionMapFile = GetVersionMapFile ( task , generatedFolder ) ;
10971147
10981148 {
10991149 TaskVersion ? defaultVersion = null ;
0 commit comments