@@ -308,7 +308,7 @@ public void VersionJson_Inheritance(bool commitInSourceControl, bool bareRepo)
308
308
this . InitializeSourceControl ( ) ;
309
309
}
310
310
311
- VersionOptions level1 , level2 , level3 , level2NoInherit ;
311
+ VersionOptions level1 , level2 , level3 , level2NoInherit , level2InheritButResetVersion ;
312
312
this . WriteVersionFile (
313
313
level1 = new VersionOptions
314
314
{
@@ -335,6 +335,13 @@ public void VersionJson_Inheritance(bool commitInSourceControl, bool bareRepo)
335
335
Version = SemanticVersion . Parse ( "10.1" ) ,
336
336
} ,
337
337
@"noInherit" ) ;
338
+ this . WriteVersionFile (
339
+ level2InheritButResetVersion = new VersionOptions
340
+ {
341
+ Inherit = true ,
342
+ Version = SemanticVersion . Parse ( "8.2" ) ,
343
+ } ,
344
+ @"inheritWithVersion" ) ;
338
345
339
346
Repository operatingRepo = this . Repo ;
340
347
if ( bareRepo )
@@ -368,6 +375,25 @@ public void VersionJson_Inheritance(bool commitInSourceControl, bool bareRepo)
368
375
Assert . Equal ( level2NoInherit . Version , level2NoInheritOptions . Version ) ;
369
376
Assert . Equal ( VersionOptions . DefaultVersionPrecision , level2NoInheritOptions . AssemblyVersionOrDefault . PrecisionOrDefault ) ;
370
377
Assert . False ( level2NoInheritOptions . Inherit ) ;
378
+
379
+ var level2InheritButResetVersionOptions = GetOption ( "inheritWithVersion" ) ;
380
+ Assert . Equal ( level2InheritButResetVersion . Version , level2InheritButResetVersionOptions . Version ) ;
381
+ Assert . True ( level2InheritButResetVersionOptions . Inherit ) ;
382
+
383
+ if ( commitInSourceControl )
384
+ {
385
+ int totalCommits = operatingRepo . Head . Commits . Count ( ) ;
386
+
387
+ // The version height should be the same for all those that inherit the version from the base,
388
+ // even though the inheriting files were introduced in successive commits.
389
+ Assert . Equal ( totalCommits , operatingRepo . GetVersionHeight ( ) ) ;
390
+ Assert . Equal ( totalCommits , operatingRepo . GetVersionHeight ( "foo" ) ) ;
391
+ Assert . Equal ( totalCommits , operatingRepo . GetVersionHeight ( @"foo\bar" ) ) ;
392
+
393
+ // These either don't inherit, or inherit but reset versions, so the commits were reset.
394
+ Assert . Equal ( 2 , operatingRepo . GetVersionHeight ( "noInherit" ) ) ;
395
+ Assert . Equal ( 1 , operatingRepo . GetVersionHeight ( "inheritWithVersion" ) ) ;
396
+ }
371
397
}
372
398
}
373
399
0 commit comments