Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
<Compile Include="IntegrationTests\GitHubFlow\OtherBranchTests.cs" />
<Compile Include="IntegrationTests\GitHubFlow\ReleaseBranchTests.cs" />
<Compile Include="Helpers\Constants.cs" />
<Compile Include="Helpers\NextVersionWriter.cs" />
<Compile Include="InformationalVersionBuilderTests.cs" />
<Compile Include="IntegrationTests\GitHubFlow\SupportBranchScenarios.cs" />
<Compile Include="JsonVersionBuilderTests.cs" />
Expand Down
11 changes: 0 additions & 11 deletions GitVersionCore.Tests/Helpers/NextVersionWriter.cs

This file was deleted.

72 changes: 6 additions & 66 deletions GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using GitVersion;
using GitVersion;
using LibGit2Sharp;
using NUnit.Framework;
using Shouldly;

[TestFixture]
public class MasterTests
Expand Down Expand Up @@ -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()
{
Expand All @@ -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<Exception>(() => 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");
}
Expand Down Expand Up @@ -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()
{
Expand All @@ -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");
}
Expand Down
4 changes: 1 addition & 3 deletions GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
16 changes: 0 additions & 16 deletions GitVersionCore/GitHubFlow/NextSemverCalculator.cs
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -56,23 +52,11 @@ public IEnumerable<SemanticVersion> 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))
{
Expand Down
41 changes: 0 additions & 41 deletions GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs

This file was deleted.

1 change: 0 additions & 1 deletion GitVersionCore/GitVersionCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
<Compile Include="GitHubFlow\LastTaggedReleaseFinder.cs" />
<Compile Include="GitHubFlow\MergedBranchesWithVersionFinder.cs" />
<Compile Include="GitHubFlow\NextSemverCalculator.cs" />
<Compile Include="GitHubFlow\NextVersionTxtFileFinder.cs" />
<Compile Include="GitHubFlow\OtherBranchVersionFinder.cs" />
<Compile Include="GitHubFlow\VersionTaggedCommit.cs" />
<Compile Include="GitVersionContext.cs" />
Expand Down
8 changes: 8 additions & 0 deletions GitVersionCore/GitVersionFinder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace GitVersion
{
using System;
using System.IO;
using System.Linq;
using LibGit2Sharp;

Expand All @@ -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");
Expand Down
5 changes: 2 additions & 3 deletions GitVersionCore/SemanticVersionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 0 additions & 7 deletions GitVersionExe.Tests/GitVersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.Text;
using GitVersion.Helpers;
using LibGit2Sharp;

public static class GitVersionHelper
{
Expand Down Expand Up @@ -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);
}
}