|
1 | 1 | using System;
|
| 2 | +using System.IO; |
2 | 3 | using System.Text;
|
3 | 4 |
|
4 | 5 | using GitVersion;
|
@@ -68,6 +69,53 @@ public void CacheFileIsMissing()
|
68 | 69 | info.ShouldContain("yml not found", () => info);
|
69 | 70 | }
|
70 | 71 |
|
| 72 | + |
| 73 | + [Test] |
| 74 | + public void ConfigChangeInvalidatesCache() |
| 75 | + { |
| 76 | + const string versionCacheFileContent = @" |
| 77 | +Major: 4 |
| 78 | +Minor: 10 |
| 79 | +Patch: 3 |
| 80 | +PreReleaseTag: test.19 |
| 81 | +PreReleaseTagWithDash: -test.19 |
| 82 | +PreReleaseLabel: test |
| 83 | +PreReleaseNumber: 19 |
| 84 | +BuildMetaData: |
| 85 | +BuildMetaDataPadded: |
| 86 | +FullBuildMetaData: Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f |
| 87 | +MajorMinorPatch: 4.10.3 |
| 88 | +SemVer: 4.10.3-test.19 |
| 89 | +LegacySemVer: 4.10.3-test19 |
| 90 | +LegacySemVerPadded: 4.10.3-test0019 |
| 91 | +AssemblySemVer: 4.10.3.0 |
| 92 | +FullSemVer: 4.10.3-test.19 |
| 93 | +InformationalVersion: 4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f |
| 94 | +BranchName: feature/test |
| 95 | +Sha: dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f |
| 96 | +NuGetVersionV2: 4.10.3-test0019 |
| 97 | +NuGetVersion: 4.10.3-test0019 |
| 98 | +CommitsSinceVersionSource: 19 |
| 99 | +CommitsSinceVersionSourcePadded: 0019 |
| 100 | +CommitDate: 2015-11-10 |
| 101 | +"; |
| 102 | + |
| 103 | + var versionAndBranchFinder = new ExecuteCore(fileSystem); |
| 104 | + |
| 105 | + RepositoryScope(versionAndBranchFinder, (fixture, vv) => |
| 106 | + { |
| 107 | + fileSystem.WriteAllText(vv.FileName, versionCacheFileContent); |
| 108 | + vv = versionAndBranchFinder.ExecuteGitVersion(null, null, null, null, false, fixture.RepositoryPath, null); |
| 109 | + vv.AssemblySemVer.ShouldBe("4.10.3.0"); |
| 110 | + |
| 111 | + var configPath = Path.Combine(fixture.RepositoryPath, "GitVersionConfig.yaml"); |
| 112 | + fileSystem.WriteAllText(configPath, "next-version: 5.0"); |
| 113 | + |
| 114 | + vv = versionAndBranchFinder.ExecuteGitVersion(null, null, null, null, false, fixture.RepositoryPath, null); |
| 115 | + vv.AssemblySemVer.ShouldBe("5.0.0.0"); |
| 116 | + }); |
| 117 | + } |
| 118 | + |
71 | 119 | string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFixture, VersionVariables> fixtureAction = null)
|
72 | 120 | {
|
73 | 121 | // Make sure GitVersion doesn't trigger build server mode when we are running the tests
|
|
0 commit comments