forked from dotnet/Nerdbank.GitVersioning
/
VersionFileTests.cs
478 lines (416 loc) · 22.5 KB
/
VersionFileTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LibGit2Sharp;
using Nerdbank.GitVersioning;
using Newtonsoft.Json;
using Xunit;
using Xunit.Abstractions;
using Version = System.Version;
public class VersionFileTests : RepoTestBase
{
private string versionTxtPath;
private string versionJsonPath;
public VersionFileTests(ITestOutputHelper logger)
: base(logger)
{
this.versionTxtPath = Path.Combine(this.RepoPath, VersionFile.TxtFileName);
this.versionJsonPath = Path.Combine(this.RepoPath, VersionFile.JsonFileName);
}
[Fact]
public void IsVersionDefined_Commit_Null()
{
Assert.False(VersionFile.IsVersionDefined((Commit)null));
}
[Fact]
public void IsVersionDefined_String_NullOrEmpty()
{
Assert.Throws<ArgumentNullException>(() => VersionFile.IsVersionDefined((string)null));
Assert.Throws<ArgumentException>(() => VersionFile.IsVersionDefined(string.Empty));
}
[Fact]
public void IsVersionDefined_Commit()
{
this.InitializeSourceControl();
this.AddCommits();
Assert.False(VersionFile.IsVersionDefined(this.Repo.Head.Commits.First()));
this.WriteVersionFile();
// Verify that we can find the version.txt file in the most recent commit,
// But not in the initial commit.
Assert.True(VersionFile.IsVersionDefined(this.Repo.Head.Commits.First()));
Assert.False(VersionFile.IsVersionDefined(this.Repo.Head.Commits.Last()));
}
[Fact]
public void IsVersionDefined_String_ConsiderAncestorFolders()
{
// Construct a repo where versions are defined like this:
/* root <- 1.0
a (inherits 1.0)
b <- 1.1
c (inherits 1.1)
*/
VersionFile.SetVersion(this.RepoPath, new Version(1, 0));
string subDirA = Path.Combine(this.RepoPath, "a");
string subDirAB = Path.Combine(subDirA, "b");
string subDirABC = Path.Combine(subDirAB, "c");
Directory.CreateDirectory(subDirABC);
VersionFile.SetVersion(subDirAB, new Version(1, 1));
Assert.True(VersionFile.IsVersionDefined(subDirABC));
Assert.True(VersionFile.IsVersionDefined(subDirAB));
Assert.True(VersionFile.IsVersionDefined(subDirA));
Assert.True(VersionFile.IsVersionDefined(this.RepoPath));
}
[Theory]
[InlineData("2.3", null, null, 0, null, @"{""version"":""2.3""}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, 0, null, @"{""version"":""2.3"",""assemblyVersion"":""2.2""}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, -1, new[] { "refs/heads/master" }, @"{""version"":""2.3"",""assemblyVersion"":""2.2"",""versionHeightOffset"":-1,""publicReleaseRefSpec"":[""refs/heads/master""]}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, -1, new[] { "refs/heads/master" }, @"{""version"":""2.3"",""assemblyVersion"":""2.2"",""buildNumberOffset"":-1,""publicReleaseRefSpec"":[""refs/heads/master""]}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, 0, null, @"{""version"":""2.3"",""assemblyVersion"":{""version"":""2.2""}}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Revision, 0, null, @"{""version"":""2.3"",""assemblyVersion"":{""version"":""2.2"", ""precision"":""revision""}}")]
public void GetVersion_JsonCompatibility(string version, string assemblyVersion, object precision, int versionHeightOffset, string[] publicReleaseRefSpec, string json)
{
File.WriteAllText(Path.Combine(this.RepoPath, VersionFile.JsonFileName), json);
var options = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(options);
Assert.Equal(version, options.Version?.ToString());
Assert.Equal(assemblyVersion, options.AssemblyVersion?.Version?.ToString());
Assert.Equal(precision, options.AssemblyVersion?.PrecisionOrDefault);
Assert.Equal(versionHeightOffset, options.VersionHeightOffsetOrDefault);
Assert.Equal(publicReleaseRefSpec, options.PublicReleaseRefSpec);
}
[Theory]
[InlineData("2.3", "")]
[InlineData("2.3", null)]
[InlineData("2.3", "-beta")]
[InlineData("2.3.0", "")]
[InlineData("2.3.0", "-rc")]
public void SetVersion_GetVersionFromFile(string expectedVersion, string expectedPrerelease)
{
string pathWritten = VersionFile.SetVersion(this.RepoPath, new Version(expectedVersion), expectedPrerelease);
Assert.Equal(Path.Combine(this.RepoPath, VersionFile.JsonFileName), pathWritten);
string actualFileContent = File.ReadAllText(pathWritten);
this.Logger.WriteLine(actualFileContent);
VersionOptions actualVersion = VersionFile.GetVersion(this.RepoPath);
Assert.Equal(new Version(expectedVersion), actualVersion.Version.Version);
Assert.Equal(expectedPrerelease ?? string.Empty, actualVersion.Version.Prerelease);
}
[Theory]
[InlineData("2.3", null, VersionOptions.VersionPrecision.Minor, 0, false, @"{""version"":""2.3""}")]
[InlineData("2.3", null, VersionOptions.VersionPrecision.Minor, null, true, @"{""version"":""2.3"",""assemblyVersion"":{""precision"":""minor""},""inherit"":true}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, 0, false, @"{""version"":""2.3"",""assemblyVersion"":""2.2""}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Minor, -1, false, @"{""version"":""2.3"",""assemblyVersion"":""2.2"",""versionHeightOffset"":-1}")]
[InlineData("2.3", "2.2", VersionOptions.VersionPrecision.Revision, -1, false, @"{""version"":""2.3"",""assemblyVersion"":{""version"":""2.2"",""precision"":""revision""},""versionHeightOffset"":-1}")]
public void SetVersion_WritesSimplestFile(string version, string assemblyVersion, VersionOptions.VersionPrecision? precision, int? versionHeightOffset, bool inherit, string expectedJson)
{
var versionOptions = new VersionOptions
{
Version = SemanticVersion.Parse(version),
AssemblyVersion = assemblyVersion != null || precision != null ? new VersionOptions.AssemblyVersionOptions(assemblyVersion != null ? new Version(assemblyVersion) : null, precision) : null,
VersionHeightOffset = versionHeightOffset,
Inherit = inherit,
};
string pathWritten = VersionFile.SetVersion(this.RepoPath, versionOptions, includeSchemaProperty: false);
string actualFileContent = File.ReadAllText(pathWritten);
this.Logger.WriteLine(actualFileContent);
string normalizedFileContent = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(actualFileContent));
Assert.Equal(expectedJson, normalizedFileContent);
}
[Theory]
[InlineData(@"{""cloudBuild"":{""buildNumber"":{""enabled"":false,""includeCommitId"":{""when"":""nonPublicReleaseOnly"",""where"":""buildMetadata""}}}}", @"{}")]
[InlineData(@"{""cloudBuild"":{""buildNumber"":{""enabled"":true,""includeCommitId"":{""when"":""nonPublicReleaseOnly"",""where"":""buildMetadata""}}}}", @"{""cloudBuild"":{""buildNumber"":{""enabled"":true}}}")]
[InlineData(@"{""cloudBuild"":{""buildNumber"":{""enabled"":true,""includeCommitId"":{""when"":""always"",""where"":""buildMetadata""}}}}", @"{""cloudBuild"":{""buildNumber"":{""enabled"":true,""includeCommitId"":{""when"":""always""}}}}")]
[InlineData(@"{""cloudBuild"":{""buildNumber"":{""enabled"":true,""includeCommitId"":{""when"":""nonPublicReleaseOnly"",""where"":""fourthVersionComponent""}}}}", @"{""cloudBuild"":{""buildNumber"":{""enabled"":true,""includeCommitId"":{""where"":""fourthVersionComponent""}}}}")]
[InlineData(@"{""cloudBuild"":{""setVersionVariables"":true}}", @"{}")]
[InlineData(@"{""cloudBuild"":{""setAllVariables"":false}}", @"{}")]
[InlineData(@"{""release"":{""increment"":""minor""}}", @"{}")]
[InlineData(@"{""release"":{""branchName"":""v{version}""}}", @"{}")]
[InlineData(@"{""release"":{""firstUnstableTag"":""alpha""}}", @"{}")]
[InlineData(@"{""release"":{""gitCommitIdPrefix"":""g""}}", @"{}")]
[InlineData(@"{""release"":{""firstUnstableTag"":""tag""}}", @"{""release"":{""firstUnstableTag"":""tag""}}")]
[InlineData(@"{""release"":{""branchName"":""v{version}"",""versionIncrement"":""minor"",""firstUnstableTag"":""alpha""}}", @"{}")]
[InlineData(@"{""release"":{""versionIncrement"":""major""}}", @"{""release"":{""versionIncrement"":""major""}}")]
[InlineData(@"{""release"":{""branchName"":""someName""}}", @"{""release"":{""branchName"":""someName""}}")]
[InlineData(@"{""release"":{""branchName"":""someName"",""versionIncrement"":""major""}}", @"{""release"":{""branchName"":""someName"",""versionIncrement"":""major""}}")]
[InlineData(@"{""release"":{""branchName"":""someName"",""versionIncrement"":""major"",""firstUnstableTag"":""alpha""}}", @"{""release"":{""branchName"":""someName"",""versionIncrement"":""major""}}")]
[InlineData(@"{""release"":{""branchName"":""someName"",""versionIncrement"":""major"",""firstUnstableTag"":""pre""}}", @"{""release"":{""branchName"":""someName"",""versionIncrement"":""major"",""firstUnstableTag"":""pre""}}")]
public void JsonMinification(string full, string minimal)
{
var settings = VersionOptions.GetJsonSettings();
settings.Formatting = Formatting.None;
// Assert that the two representations are equivalent.
var fullVersion = JsonConvert.DeserializeObject<VersionOptions>(full, settings);
var minimalVersion = JsonConvert.DeserializeObject<VersionOptions>(minimal, settings);
Assert.Equal(fullVersion, minimalVersion);
string fullVersionSerialized = JsonConvert.SerializeObject(fullVersion, settings);
Assert.Equal(minimal, fullVersionSerialized);
}
[Fact]
public void GetVersion_CanReadSpecConformantJsonFile()
{
File.WriteAllText(Path.Combine(this.RepoPath, VersionFile.JsonFileName), "{ version: \"1.2-pre\" }");
VersionOptions actualVersion = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(actualVersion);
Assert.Equal(new Version(1, 2), actualVersion.Version.Version);
Assert.Equal("-pre", actualVersion.Version.Prerelease);
}
[Fact]
public void GetVersion_CanReadSpecConformantTxtFile_SingleLine()
{
File.WriteAllText(Path.Combine(this.RepoPath, VersionFile.TxtFileName), "1.2-pre");
VersionOptions actualVersion = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(actualVersion);
Assert.Equal(new Version(1, 2), actualVersion.Version.Version);
Assert.Equal("-pre", actualVersion.Version.Prerelease);
}
[Fact]
public void GetVersion_CanReadSpecConformantTxtFile_MultiLine()
{
File.WriteAllText(Path.Combine(this.RepoPath, VersionFile.TxtFileName), "1.2\n-pre");
VersionOptions actualVersion = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(actualVersion);
Assert.Equal(new Version(1, 2), actualVersion.Version.Version);
Assert.Equal("-pre", actualVersion.Version.Prerelease);
}
[Fact]
public void GetVersion_CanReadSpecConformantTxtFile_MultiLineNoHyphen()
{
File.WriteAllText(Path.Combine(this.RepoPath, VersionFile.TxtFileName), "1.2\npre");
VersionOptions actualVersion = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(actualVersion);
Assert.Equal(new Version(1, 2), actualVersion.Version.Version);
Assert.Equal("-pre", actualVersion.Version.Prerelease);
}
[Fact]
public void GetVersion_Commit()
{
Assert.Null(VersionFile.GetVersion((Commit)null));
this.InitializeSourceControl();
this.WriteVersionFile();
VersionOptions fromCommit = VersionFile.GetVersion(this.Repo.Head.Commits.First());
VersionOptions fromFile = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(fromCommit);
Assert.Equal(fromFile, fromCommit);
}
[Fact]
public void GetVersion_String_FindsNearestFileInAncestorDirectories()
{
// Construct a repo where versions are defined like this:
/* root <- 1.0
a (inherits 1.0)
b <- 1.1
c (inherits 1.1)
*/
var rootVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("1.0") };
var subdirVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("1.1") };
VersionFile.SetVersion(this.RepoPath, rootVersionSpec);
string subDirA = Path.Combine(this.RepoPath, "a");
string subDirAB = Path.Combine(subDirA, "b");
string subDirABC = Path.Combine(subDirAB, "c");
Directory.CreateDirectory(subDirABC);
VersionFile.SetVersion(subDirAB, new Version(1, 1));
this.InitializeSourceControl();
var commit = this.Repo.Head.Commits.First();
this.AssertPathHasVersion(commit, subDirABC, subdirVersionSpec);
this.AssertPathHasVersion(commit, subDirAB, subdirVersionSpec);
this.AssertPathHasVersion(commit, subDirA, rootVersionSpec);
this.AssertPathHasVersion(commit, this.RepoPath, rootVersionSpec);
}
[Fact]
public void GetVersion_String_FindsNearestFileInAncestorDirectories_WithAssemblyVersion()
{
// Construct a repo where versions are defined like this:
/* root <- 14.0
a (inherits 14.0)
b <- 11.0
c (inherits 11.0)
*/
var rootVersionSpec = new VersionOptions
{
Version = SemanticVersion.Parse("14.1"),
AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version(14, 0)),
};
var subdirVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("11.0") };
VersionFile.SetVersion(this.RepoPath, rootVersionSpec);
string subDirA = Path.Combine(this.RepoPath, "a");
string subDirAB = Path.Combine(subDirA, "b");
string subDirABC = Path.Combine(subDirAB, "c");
Directory.CreateDirectory(subDirABC);
VersionFile.SetVersion(subDirAB, subdirVersionSpec);
this.InitializeSourceControl();
var commit = this.Repo.Head.Commits.First();
this.AssertPathHasVersion(commit, subDirABC, subdirVersionSpec);
this.AssertPathHasVersion(commit, subDirAB, subdirVersionSpec);
this.AssertPathHasVersion(commit, subDirA, rootVersionSpec);
this.AssertPathHasVersion(commit, this.RepoPath, rootVersionSpec);
}
[Fact]
public void GetVersion_ReadReleaseSettings_VersionIncrement()
{
var json = @"{ ""version"" : ""1.2"", ""release"" : { ""versionIncrement"" : ""major"" } }";
var path = Path.Combine(this.RepoPath, "version.json");
File.WriteAllText(path, json);
var versionOptions = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(versionOptions.Release);
Assert.NotNull(versionOptions.Release.VersionIncrement);
Assert.Equal(VersionOptions.ReleaseVersionIncrement.Major, versionOptions.Release.VersionIncrement);
}
[Fact]
public void GetVersion_ReadReleaseSettings_FirstUnstableTag()
{
var json = @"{ ""version"" : ""1.2"", ""release"" : { ""firstUnstableTag"" : ""preview"" } }";
var path = Path.Combine(this.RepoPath, "version.json");
File.WriteAllText(path, json);
var versionOptions = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(versionOptions.Release);
Assert.NotNull(versionOptions.Release.FirstUnstableTag);
Assert.Equal("preview", versionOptions.Release.FirstUnstableTag);
}
[Fact]
public void GetVersion_ReadReleaseSettings_BranchName()
{
var json = @"{ ""version"" : ""1.2"", ""release"" : { ""branchName"" : ""someValue{version}"" } }";
var path = Path.Combine(this.RepoPath, "version.json");
File.WriteAllText(path, json);
var versionOptions = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(versionOptions.Release);
Assert.NotNull(versionOptions.Release.BranchName);
Assert.Equal("someValue{version}", versionOptions.Release.BranchName);
}
[Fact]
public void GetVersion_ReadPathFilters()
{
var json = @"{ ""version"" : ""1.2"", ""pathFilters"" : [ "":/root.txt"", ""./hello"" ] }";
var path = Path.Combine(this.RepoPath, "version.json");
File.WriteAllText(path, json);
var versionOptions = VersionFile.GetVersion(this.RepoPath);
Assert.NotNull(versionOptions.PathFilters);
Assert.Equal(new[] {":/root.txt", "./hello"}, versionOptions.PathFilters);
}
[Fact]
public void GetVersion_String_MissingFile()
{
Assert.Null(VersionFile.GetVersion(this.RepoPath));
}
[Fact]
public void VersionJson_InheritButNoParentFileFound()
{
this.InitializeSourceControl();
this.WriteVersionFile(
new VersionOptions
{
Inherit = true,
Version = SemanticVersion.Parse("14.2"),
});
Assert.Throws<InvalidOperationException>(() => VersionFile.GetVersion(this.Repo));
}
[Fact]
public void VersionJson_DoNotInheritButNoVersionSpecified()
{
this.InitializeSourceControl();
Assert.Throws<ArgumentException>(() => this.WriteVersionFile(
new VersionOptions
{
Inherit = false,
}));
}
[Theory]
[InlineData(false, false)]
[InlineData(true, false)]
[InlineData(true, true)]
public void VersionJson_Inheritance(bool commitInSourceControl, bool bareRepo)
{
if (commitInSourceControl)
{
this.InitializeSourceControl();
}
VersionOptions level1, level2, level3, level2NoInherit, level2InheritButResetVersion;
this.WriteVersionFile(
level1 = new VersionOptions
{
Version = SemanticVersion.Parse("14.2"),
AssemblyVersion = new VersionOptions.AssemblyVersionOptions { Precision = VersionOptions.VersionPrecision.Major },
});
this.WriteVersionFile(
level2 = new VersionOptions
{
Inherit = true,
AssemblyVersion = new VersionOptions.AssemblyVersionOptions { Precision = VersionOptions.VersionPrecision.Minor },
},
"foo");
this.WriteVersionFile(
level3 = new VersionOptions
{
Inherit = true,
VersionHeightOffset = 1,
},
@"foo\bar");
this.WriteVersionFile(
level2NoInherit = new VersionOptions
{
Version = SemanticVersion.Parse("10.1"),
},
@"noInherit");
this.WriteVersionFile(
level2InheritButResetVersion = new VersionOptions
{
Inherit = true,
Version = SemanticVersion.Parse("8.2"),
},
@"inheritWithVersion");
Repository operatingRepo = this.Repo;
if (bareRepo)
{
operatingRepo = new Repository(
Repository.Clone(this.RepoPath, this.CreateDirectoryForNewRepo(), new CloneOptions { IsBare = true }));
}
using (operatingRepo)
{
VersionOptions GetOption(string path) => commitInSourceControl ? VersionFile.GetVersion(operatingRepo, path) : VersionFile.GetVersion(Path.Combine(this.RepoPath, path));
var level1Options = GetOption(string.Empty);
Assert.False(level1Options.Inherit);
var level2Options = GetOption("foo");
Assert.Equal(level1.Version.Version.Major, level2Options.Version.Version.Major);
Assert.Equal(level1.Version.Version.Minor, level2Options.Version.Version.Minor);
Assert.Equal(level2.AssemblyVersion.Precision, level2Options.AssemblyVersion.Precision);
Assert.True(level2Options.Inherit);
var level3Options = GetOption(@"foo\bar");
Assert.Equal(level1.Version.Version.Major, level3Options.Version.Version.Major);
Assert.Equal(level1.Version.Version.Minor, level3Options.Version.Version.Minor);
Assert.Equal(level2.AssemblyVersion.Precision, level3Options.AssemblyVersion.Precision);
Assert.Equal(level2.AssemblyVersion.Precision, level3Options.AssemblyVersion.Precision);
Assert.Equal(level3.VersionHeightOffset, level3Options.VersionHeightOffset);
Assert.True(level3Options.Inherit);
var level2NoInheritOptions = GetOption("noInherit");
Assert.Equal(level2NoInherit.Version, level2NoInheritOptions.Version);
Assert.Equal(VersionOptions.DefaultVersionPrecision, level2NoInheritOptions.AssemblyVersionOrDefault.PrecisionOrDefault);
Assert.False(level2NoInheritOptions.Inherit);
var level2InheritButResetVersionOptions = GetOption("inheritWithVersion");
Assert.Equal(level2InheritButResetVersion.Version, level2InheritButResetVersionOptions.Version);
Assert.True(level2InheritButResetVersionOptions.Inherit);
if (commitInSourceControl)
{
int totalCommits = operatingRepo.Head.Commits.Count();
// The version height should be the same for all those that inherit the version from the base,
// even though the inheriting files were introduced in successive commits.
Assert.Equal(totalCommits, operatingRepo.GetVersionHeight());
Assert.Equal(totalCommits, operatingRepo.GetVersionHeight("foo"));
Assert.Equal(totalCommits, operatingRepo.GetVersionHeight(@"foo\bar"));
// These either don't inherit, or inherit but reset versions, so the commits were reset.
Assert.Equal(2, operatingRepo.GetVersionHeight("noInherit"));
Assert.Equal(1, operatingRepo.GetVersionHeight("inheritWithVersion"));
}
}
}
private void AssertPathHasVersion(Commit commit, string absolutePath, VersionOptions expected)
{
var actual = VersionFile.GetVersion(absolutePath);
Assert.Equal(expected, actual);
// Pass in the repo-relative path to ensure the commit is used as the data source.
string relativePath = absolutePath.Substring(this.RepoPath.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
actual = VersionFile.GetVersion(commit, relativePath);
Assert.Equal(expected, actual);
}
}