Skip to content

Commit 7b59651

Browse files
committed
Merge pull request #345 from JakeGinnivan/NoMoreNextVersionTxt
Deprecated NextVersion.txt
2 parents 95e744e + ea0e316 commit 7b59651

File tree

10 files changed

+17
-149
lines changed

10 files changed

+17
-149
lines changed

GitVersionCore.Tests/GitVersionCore.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
<Compile Include="IntegrationTests\GitHubFlow\OtherBranchTests.cs" />
8989
<Compile Include="IntegrationTests\GitHubFlow\ReleaseBranchTests.cs" />
9090
<Compile Include="Helpers\Constants.cs" />
91-
<Compile Include="Helpers\NextVersionWriter.cs" />
9291
<Compile Include="InformationalVersionBuilderTests.cs" />
9392
<Compile Include="IntegrationTests\GitHubFlow\SupportBranchScenarios.cs" />
9493
<Compile Include="JsonVersionBuilderTests.cs" />

GitVersionCore.Tests/Helpers/NextVersionWriter.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
using GitVersion;
1+
using GitVersion;
32
using LibGit2Sharp;
43
using NUnit.Framework;
5-
using Shouldly;
64

75
[TestFixture]
86
public class MasterTests
@@ -41,36 +39,6 @@ public void GivenARepositoryWithCommitsButNoTagsWithDetachedHead_VersionShouldBe
4139
}
4240
}
4341

44-
[Test]
45-
public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
46-
{
47-
using (var fixture = new EmptyRepositoryFixture(new Config()))
48-
{
49-
const string ExpectedNextVersion = "1.0.0";
50-
fixture.Repository.MakeACommit();
51-
fixture.Repository.MakeACommit();
52-
fixture.Repository.MakeACommit();
53-
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
54-
55-
fixture.AssertFullSemver("1.0.0+2");
56-
}
57-
}
58-
59-
[Test]
60-
public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
61-
{
62-
using (var fixture = new EmptyRepositoryFixture(new Config()))
63-
{
64-
const string ExpectedNextVersion = "1.1.0";
65-
const string TaggedVersion = "1.0.3";
66-
fixture.Repository.MakeATaggedCommit(TaggedVersion);
67-
fixture.Repository.MakeCommits(5);
68-
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
69-
70-
fixture.AssertFullSemver("1.1.0+5");
71-
}
72-
}
73-
7442
[Test]
7543
public void GivenARepositoryWithTagAndNextVersionInConfig_VersionShouldMatchVersionTxtFile()
7644
{
@@ -85,26 +53,14 @@ public void GivenARepositoryWithTagAndNextVersionInConfig_VersionShouldMatchVers
8553
}
8654
}
8755

88-
[Test]
89-
public void GivenARepositoryWithANextVersionTxtFileAndNextVersionInConfig_ErrorIsThrown()
90-
{
91-
using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = "1.1.0" }))
92-
{
93-
fixture.Repository.AddNextVersionTxtFile("1.1.0");
94-
95-
Should.Throw<Exception>(() => fixture.AssertFullSemver("1.1.0+5"));
96-
}
97-
}
98-
9956
[Test]
10057
public void GivenARepositoryWithTagAndANextVersionTxtFileAndNoCommits_VersionShouldBeTag()
10158
{
102-
using (var fixture = new EmptyRepositoryFixture(new Config()))
103-
{
10459
const string ExpectedNextVersion = "1.1.0";
60+
using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = ExpectedNextVersion }))
61+
{
10562
const string TaggedVersion = "1.0.3";
10663
fixture.Repository.MakeATaggedCommit(TaggedVersion);
107-
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
10864

10965
fixture.AssertFullSemver("1.0.3+0");
11066
}
@@ -135,21 +91,6 @@ public void GivenARepositoryWithTagAndNoNextVersionTxtFileAndNoCommits_VersionSh
13591
}
13692
}
13793

138-
[Test]
139-
public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch()
140-
{
141-
using (var fixture = new EmptyRepositoryFixture(new Config()))
142-
{
143-
const string NextVersionTxt = "1.0.0";
144-
const string TaggedVersion = "1.1.0";
145-
fixture.Repository.MakeATaggedCommit(TaggedVersion);
146-
fixture.Repository.MakeCommits(5);
147-
fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
148-
149-
fixture.AssertFullSemver("1.1.1+5");
150-
}
151-
}
152-
15394
[Test]
15495
public void GivenARepositoryWithTagAndOldNextVersionConfig_VersionShouldBeTagWithBumpedPatch()
15596
{
@@ -165,14 +106,13 @@ public void GivenARepositoryWithTagAndOldNextVersionConfig_VersionShouldBeTagWit
165106
}
166107

167108
[Test]
168-
public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionShouldBeTag()
109+
public void GivenARepositoryWithTagAndOldNextVersionConfigAndNoCommits_VersionShouldBeTag()
169110
{
170-
using (var fixture = new EmptyRepositoryFixture(new Config()))
111+
const string NextVersionConfig = "1.0.0";
112+
using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = NextVersionConfig }))
171113
{
172-
const string NextVersionTxt = "1.0.0";
173114
const string TaggedVersion = "1.1.0";
174115
fixture.Repository.MakeATaggedCommit(TaggedVersion);
175-
fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
176116

177117
fixture.AssertFullSemver("1.1.0+0");
178118
}

GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ public class GitHubFlowVersionFinder
44
{
55
public SemanticVersion FindVersion(GitVersionContext context)
66
{
7-
var repositoryDirectory = context.Repository.Info.WorkingDirectory;
87
var lastTaggedReleaseFinder = new LastTaggedReleaseFinder(context);
9-
var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repositoryDirectory, context.Configuration);
10-
var nextSemverCalculator = new NextSemverCalculator(nextVersionTxtFileFinder, lastTaggedReleaseFinder, context);
8+
var nextSemverCalculator = new NextSemverCalculator(lastTaggedReleaseFinder, context);
119
return new BuildNumberCalculator(nextSemverCalculator, lastTaggedReleaseFinder, context.Repository).GetBuildNumber(context);
1210
}
1311
}

GitVersionCore/GitHubFlow/NextSemverCalculator.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
namespace GitVersion
22
{
3-
using System;
43
using System.Collections.Generic;
54
using System.Linq;
65

76
public class NextSemverCalculator
87
{
9-
NextVersionTxtFileFinder nextVersionTxtFileFinder;
108
LastTaggedReleaseFinder lastTaggedReleaseFinder;
119
OtherBranchVersionFinder unknownBranchFinder;
1210
GitVersionContext context;
1311
MergedBranchesWithVersionFinder mergedBranchesWithVersionFinder;
1412

1513
public NextSemverCalculator(
16-
NextVersionTxtFileFinder nextVersionTxtFileFinder,
1714
LastTaggedReleaseFinder lastTaggedReleaseFinder,
1815
GitVersionContext context)
1916
{
20-
this.nextVersionTxtFileFinder = nextVersionTxtFileFinder;
2117
this.lastTaggedReleaseFinder = lastTaggedReleaseFinder;
2218
mergedBranchesWithVersionFinder = new MergedBranchesWithVersionFinder(context);
2319
unknownBranchFinder = new OtherBranchVersionFinder();
@@ -56,23 +52,11 @@ public IEnumerable<SemanticVersion> GetPossibleVersions()
5652
yield return defaultNextVersion;
5753
}
5854

59-
SemanticVersion fileVersion;
60-
var hasNextVersionTxtVersion = nextVersionTxtFileFinder.TryGetNextVersion(out fileVersion);
61-
if (hasNextVersionTxtVersion && !string.IsNullOrEmpty(context.Configuration.NextVersion))
62-
{
63-
throw new Exception("You cannot specify a next version in both NextVersion.txt and GitVersionConfig.yaml. Please delete NextVersion.txt and use GitVersionConfig.yaml");
64-
}
65-
6655
if (!string.IsNullOrEmpty(context.Configuration.NextVersion))
6756
{
6857
yield return SemanticVersion.Parse(context.Configuration.NextVersion, context.Configuration.GitTagPrefix);
6958
}
7059

71-
if (hasNextVersionTxtVersion)
72-
{
73-
yield return fileVersion;
74-
}
75-
7660
SemanticVersion tryGetVersion;
7761
if (mergedBranchesWithVersionFinder.TryGetVersion(out tryGetVersion))
7862
{

GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

GitVersionCore/GitVersionCore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
<Compile Include="GitHubFlow\LastTaggedReleaseFinder.cs" />
113113
<Compile Include="GitHubFlow\MergedBranchesWithVersionFinder.cs" />
114114
<Compile Include="GitHubFlow\NextSemverCalculator.cs" />
115-
<Compile Include="GitHubFlow\NextVersionTxtFileFinder.cs" />
116115
<Compile Include="GitHubFlow\OtherBranchVersionFinder.cs" />
117116
<Compile Include="GitHubFlow\VersionTaggedCommit.cs" />
118117
<Compile Include="GitVersionContext.cs" />

GitVersionCore/GitVersionFinder.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace GitVersion
22
{
3+
using System;
4+
using System.IO;
35
using System.Linq;
46
using LibGit2Sharp;
57

@@ -10,6 +12,12 @@ public SemanticVersion FindVersion(GitVersionContext context)
1012
Logger.WriteInfo("Running against branch: " + context.CurrentBranch.Name);
1113
EnsureMainTopologyConstraints(context);
1214

15+
var filePath = Path.Combine(context.Repository.GetRepositoryDirectory(), "NextVersion.txt");
16+
if (File.Exists(filePath))
17+
{
18+
throw new Exception("NextVersion.txt has been depreciated. See https://github.com/ParticularLabs/GitVersion/wiki/GitVersionConfig.yaml-Configuration-File for replacement");
19+
}
20+
1321
if (ShouldGitHubFlowVersioningSchemeApply(context.Repository))
1422
{
1523
Logger.WriteInfo("GitHubFlow version strategy will be used");

GitVersionCore/SemanticVersionExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ public static class SemanticVersionExtensions
66
{
77
public static void OverrideVersionManuallyIfNeeded(this SemanticVersion version, IRepository repository, EffectiveConfiguration configuration)
88
{
9-
var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repository.GetRepositoryDirectory(), configuration);
10-
SemanticVersion manualNextVersion ;
11-
if (nextVersionTxtFileFinder.TryGetNextVersion(out manualNextVersion))
9+
SemanticVersion manualNextVersion;
10+
if (!string.IsNullOrEmpty(configuration.NextVersion) && SemanticVersion.TryParse(configuration.NextVersion, configuration.GitTagPrefix, out manualNextVersion))
1211
{
1312
if (manualNextVersion > version)
1413
{

GitVersionExe.Tests/GitVersionHelper.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.IO;
44
using System.Text;
55
using GitVersion.Helpers;
6-
using LibGit2Sharp;
76

87
public static class GitVersionHelper
98
{
@@ -62,10 +61,4 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
6261

6362
return new ExecutionResults(exitCode, output.ToString(), logContents);
6463
}
65-
66-
public static void AddNextVersionTxtFile(this IRepository repository, string version)
67-
{
68-
var nextVersionFile = Path.Combine(repository.Info.WorkingDirectory, "NextVersion.txt");
69-
File.WriteAllText(nextVersionFile, version);
70-
}
7164
}

0 commit comments

Comments
 (0)