diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj
index 1ee1fb42dc..71ec916ba2 100644
--- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj
+++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj
@@ -88,7 +88,6 @@
-
diff --git a/GitVersionCore.Tests/Helpers/NextVersionWriter.cs b/GitVersionCore.Tests/Helpers/NextVersionWriter.cs
deleted file mode 100644
index 553babf058..0000000000
--- a/GitVersionCore.Tests/Helpers/NextVersionWriter.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.IO;
-using LibGit2Sharp;
-
-public static class NextVersionWriter
-{
- public static void AddNextVersionTxtFile(this IRepository repository, string version)
- {
- var nextVersionFile = Path.Combine(repository.Info.WorkingDirectory, "NextVersion.txt");
- File.WriteAllText(nextVersionFile, version);
- }
-}
\ No newline at end of file
diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs
index 29337f7004..994e515cbb 100644
--- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs
+++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs
@@ -1,8 +1,6 @@
-using System;
-using GitVersion;
+using GitVersion;
using LibGit2Sharp;
using NUnit.Framework;
-using Shouldly;
[TestFixture]
public class MasterTests
@@ -41,36 +39,6 @@ public void GivenARepositoryWithCommitsButNoTagsWithDetachedHead_VersionShouldBe
}
}
- [Test]
- public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
- {
- using (var fixture = new EmptyRepositoryFixture(new Config()))
- {
- const string ExpectedNextVersion = "1.0.0";
- fixture.Repository.MakeACommit();
- fixture.Repository.MakeACommit();
- fixture.Repository.MakeACommit();
- fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
-
- fixture.AssertFullSemver("1.0.0+2");
- }
- }
-
- [Test]
- public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
- {
- using (var fixture = new EmptyRepositoryFixture(new Config()))
- {
- const string ExpectedNextVersion = "1.1.0";
- const string TaggedVersion = "1.0.3";
- fixture.Repository.MakeATaggedCommit(TaggedVersion);
- fixture.Repository.MakeCommits(5);
- fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
-
- fixture.AssertFullSemver("1.1.0+5");
- }
- }
-
[Test]
public void GivenARepositoryWithTagAndNextVersionInConfig_VersionShouldMatchVersionTxtFile()
{
@@ -85,26 +53,14 @@ public void GivenARepositoryWithTagAndNextVersionInConfig_VersionShouldMatchVers
}
}
- [Test]
- public void GivenARepositoryWithANextVersionTxtFileAndNextVersionInConfig_ErrorIsThrown()
- {
- using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = "1.1.0" }))
- {
- fixture.Repository.AddNextVersionTxtFile("1.1.0");
-
- Should.Throw(() => fixture.AssertFullSemver("1.1.0+5"));
- }
- }
-
[Test]
public void GivenARepositoryWithTagAndANextVersionTxtFileAndNoCommits_VersionShouldBeTag()
{
- using (var fixture = new EmptyRepositoryFixture(new Config()))
- {
const string ExpectedNextVersion = "1.1.0";
+ using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = ExpectedNextVersion }))
+ {
const string TaggedVersion = "1.0.3";
fixture.Repository.MakeATaggedCommit(TaggedVersion);
- fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
fixture.AssertFullSemver("1.0.3+0");
}
@@ -135,21 +91,6 @@ public void GivenARepositoryWithTagAndNoNextVersionTxtFileAndNoCommits_VersionSh
}
}
- [Test]
- public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch()
- {
- using (var fixture = new EmptyRepositoryFixture(new Config()))
- {
- const string NextVersionTxt = "1.0.0";
- const string TaggedVersion = "1.1.0";
- fixture.Repository.MakeATaggedCommit(TaggedVersion);
- fixture.Repository.MakeCommits(5);
- fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
-
- fixture.AssertFullSemver("1.1.1+5");
- }
- }
-
[Test]
public void GivenARepositoryWithTagAndOldNextVersionConfig_VersionShouldBeTagWithBumpedPatch()
{
@@ -165,14 +106,13 @@ public void GivenARepositoryWithTagAndOldNextVersionConfig_VersionShouldBeTagWit
}
[Test]
- public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionShouldBeTag()
+ public void GivenARepositoryWithTagAndOldNextVersionConfigAndNoCommits_VersionShouldBeTag()
{
- using (var fixture = new EmptyRepositoryFixture(new Config()))
+ const string NextVersionConfig = "1.0.0";
+ using (var fixture = new EmptyRepositoryFixture(new Config { NextVersion = NextVersionConfig }))
{
- const string NextVersionTxt = "1.0.0";
const string TaggedVersion = "1.1.0";
fixture.Repository.MakeATaggedCommit(TaggedVersion);
- fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
fixture.AssertFullSemver("1.1.0+0");
}
diff --git a/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs b/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs
index 264b83760d..d80c2db44a 100644
--- a/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs
+++ b/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs
@@ -4,10 +4,8 @@ public class GitHubFlowVersionFinder
{
public SemanticVersion FindVersion(GitVersionContext context)
{
- var repositoryDirectory = context.Repository.Info.WorkingDirectory;
var lastTaggedReleaseFinder = new LastTaggedReleaseFinder(context);
- var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repositoryDirectory, context.Configuration);
- var nextSemverCalculator = new NextSemverCalculator(nextVersionTxtFileFinder, lastTaggedReleaseFinder, context);
+ var nextSemverCalculator = new NextSemverCalculator(lastTaggedReleaseFinder, context);
return new BuildNumberCalculator(nextSemverCalculator, lastTaggedReleaseFinder, context.Repository).GetBuildNumber(context);
}
}
diff --git a/GitVersionCore/GitHubFlow/NextSemverCalculator.cs b/GitVersionCore/GitHubFlow/NextSemverCalculator.cs
index fd5af2df44..61523c6308 100644
--- a/GitVersionCore/GitHubFlow/NextSemverCalculator.cs
+++ b/GitVersionCore/GitHubFlow/NextSemverCalculator.cs
@@ -1,23 +1,19 @@
namespace GitVersion
{
- using System;
using System.Collections.Generic;
using System.Linq;
public class NextSemverCalculator
{
- NextVersionTxtFileFinder nextVersionTxtFileFinder;
LastTaggedReleaseFinder lastTaggedReleaseFinder;
OtherBranchVersionFinder unknownBranchFinder;
GitVersionContext context;
MergedBranchesWithVersionFinder mergedBranchesWithVersionFinder;
public NextSemverCalculator(
- NextVersionTxtFileFinder nextVersionTxtFileFinder,
LastTaggedReleaseFinder lastTaggedReleaseFinder,
GitVersionContext context)
{
- this.nextVersionTxtFileFinder = nextVersionTxtFileFinder;
this.lastTaggedReleaseFinder = lastTaggedReleaseFinder;
mergedBranchesWithVersionFinder = new MergedBranchesWithVersionFinder(context);
unknownBranchFinder = new OtherBranchVersionFinder();
@@ -56,23 +52,11 @@ public IEnumerable GetPossibleVersions()
yield return defaultNextVersion;
}
- SemanticVersion fileVersion;
- var hasNextVersionTxtVersion = nextVersionTxtFileFinder.TryGetNextVersion(out fileVersion);
- if (hasNextVersionTxtVersion && !string.IsNullOrEmpty(context.Configuration.NextVersion))
- {
- throw new Exception("You cannot specify a next version in both NextVersion.txt and GitVersionConfig.yaml. Please delete NextVersion.txt and use GitVersionConfig.yaml");
- }
-
if (!string.IsNullOrEmpty(context.Configuration.NextVersion))
{
yield return SemanticVersion.Parse(context.Configuration.NextVersion, context.Configuration.GitTagPrefix);
}
- if (hasNextVersionTxtVersion)
- {
- yield return fileVersion;
- }
-
SemanticVersion tryGetVersion;
if (mergedBranchesWithVersionFinder.TryGetVersion(out tryGetVersion))
{
diff --git a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs
deleted file mode 100644
index 83183de9e8..0000000000
--- a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace GitVersion
-{
- using System;
- using System.IO;
-
- public class NextVersionTxtFileFinder
- {
- EffectiveConfiguration configuration;
- string repositoryDirectory;
-
- public NextVersionTxtFileFinder(string repositoryDirectory, EffectiveConfiguration configuration)
- {
- this.repositoryDirectory = repositoryDirectory;
- this.configuration = configuration;
- }
-
- public bool TryGetNextVersion(out SemanticVersion semanticVersion)
- {
- var filePath = Path.Combine(repositoryDirectory, "NextVersion.txt");
- if (!File.Exists(filePath))
- {
- semanticVersion = null;
- return false;
- }
-
- var version = File.ReadAllText(filePath);
- if (string.IsNullOrEmpty(version))
- {
- semanticVersion = null;
- return false;
- }
-
- if (!SemanticVersion.TryParse(version, configuration.GitTagPrefix, out semanticVersion))
- {
- throw new ArgumentException("Make sure you have a valid semantic version in NextVersion.txt");
- }
-
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/GitVersionCore/GitVersionCore.csproj b/GitVersionCore/GitVersionCore.csproj
index d48023d345..6b10e87892 100644
--- a/GitVersionCore/GitVersionCore.csproj
+++ b/GitVersionCore/GitVersionCore.csproj
@@ -110,7 +110,6 @@
-
diff --git a/GitVersionCore/GitVersionFinder.cs b/GitVersionCore/GitVersionFinder.cs
index 418c934ec7..c9faa91e15 100644
--- a/GitVersionCore/GitVersionFinder.cs
+++ b/GitVersionCore/GitVersionFinder.cs
@@ -1,5 +1,7 @@
namespace GitVersion
{
+ using System;
+ using System.IO;
using System.Linq;
using LibGit2Sharp;
@@ -10,6 +12,12 @@ public SemanticVersion FindVersion(GitVersionContext context)
Logger.WriteInfo("Running against branch: " + context.CurrentBranch.Name);
EnsureMainTopologyConstraints(context);
+ var filePath = Path.Combine(context.Repository.GetRepositoryDirectory(), "NextVersion.txt");
+ if (File.Exists(filePath))
+ {
+ throw new Exception("NextVersion.txt has been depreciated. See https://github.com/ParticularLabs/GitVersion/wiki/GitVersionConfig.yaml-Configuration-File for replacement");
+ }
+
if (ShouldGitHubFlowVersioningSchemeApply(context.Repository))
{
Logger.WriteInfo("GitHubFlow version strategy will be used");
diff --git a/GitVersionCore/SemanticVersionExtensions.cs b/GitVersionCore/SemanticVersionExtensions.cs
index af63364186..5780f97c0d 100644
--- a/GitVersionCore/SemanticVersionExtensions.cs
+++ b/GitVersionCore/SemanticVersionExtensions.cs
@@ -6,9 +6,8 @@ public static class SemanticVersionExtensions
{
public static void OverrideVersionManuallyIfNeeded(this SemanticVersion version, IRepository repository, EffectiveConfiguration configuration)
{
- var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repository.GetRepositoryDirectory(), configuration);
- SemanticVersion manualNextVersion ;
- if (nextVersionTxtFileFinder.TryGetNextVersion(out manualNextVersion))
+ SemanticVersion manualNextVersion;
+ if (!string.IsNullOrEmpty(configuration.NextVersion) && SemanticVersion.TryParse(configuration.NextVersion, configuration.GitTagPrefix, out manualNextVersion))
{
if (manualNextVersion > version)
{
diff --git a/GitVersionExe.Tests/GitVersionHelper.cs b/GitVersionExe.Tests/GitVersionHelper.cs
index 1823f7dc3b..70a5e2d0da 100644
--- a/GitVersionExe.Tests/GitVersionHelper.cs
+++ b/GitVersionExe.Tests/GitVersionHelper.cs
@@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using GitVersion.Helpers;
-using LibGit2Sharp;
public static class GitVersionHelper
{
@@ -62,10 +61,4 @@ static ExecutionResults ExecuteIn(ArgumentBuilder arguments)
return new ExecutionResults(exitCode, output.ToString(), logContents);
}
-
- public static void AddNextVersionTxtFile(this IRepository repository, string version)
- {
- var nextVersionFile = Path.Combine(repository.Info.WorkingDirectory, "NextVersion.txt");
- File.WriteAllText(nextVersionFile, version);
- }
}
\ No newline at end of file