From c9a71122e93f1bceaced1a4eee643d64ce6fe411 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 16:27:49 +0000 Subject: [PATCH 01/17] Moved configuration files to Core --- .../ConfigReaderTests.cs | 2 +- GitVersionCore.Tests/GitVersionCore.Tests.csproj | 1 + GitVersionTask.Tests/GitVersionTask.Tests.csproj | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) rename {GitVersionTask.Tests => GitVersionCore.Tests}/ConfigReaderTests.cs (89%) diff --git a/GitVersionTask.Tests/ConfigReaderTests.cs b/GitVersionCore.Tests/ConfigReaderTests.cs similarity index 89% rename from GitVersionTask.Tests/ConfigReaderTests.cs rename to GitVersionCore.Tests/ConfigReaderTests.cs index b6138e3bf8..0d0a3e57e8 100644 --- a/GitVersionTask.Tests/ConfigReaderTests.cs +++ b/GitVersionCore.Tests/ConfigReaderTests.cs @@ -9,7 +9,7 @@ public class ConfigReaderTests public void CanReadDocument() { var text = "assemblyVersioningScheme: MajorMinor"; - var config = ConfigReader.Read(new StringReader(text)); + var config = ConfigReader.Read(new StringReader(text)); Assert.AreEqual(AssemblyVersioningScheme.MajorMinor, config.AssemblyVersioningScheme); } diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj index c7eefb60d8..dad7c23e8d 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -66,6 +66,7 @@ Helpers\DirectoryHelper.cs + diff --git a/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/GitVersionTask.Tests/GitVersionTask.Tests.csproj index d087d43e23..4ca96a71df 100644 --- a/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -92,7 +92,6 @@ - From ade1b86a9df104edb054b7d104052d4b5666d670 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 16:37:17 +0000 Subject: [PATCH 02/17] Put config files into namespaces --- GitVersionCore.Tests/ConfigReaderTests.cs | 2 ++ GitVersionCore/AssemblyVersioningScheme.cs | 11 +++++++---- GitVersionCore/Configuration/Config.cs | 7 +++++-- GitVersionCore/Configuration/ConfigReader.cs | 17 ++++++++++------- .../GitVersionTask.Tests.csproj | 4 +--- .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 3 ++- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/GitVersionCore.Tests/ConfigReaderTests.cs b/GitVersionCore.Tests/ConfigReaderTests.cs index 0d0a3e57e8..2dd6c422f2 100644 --- a/GitVersionCore.Tests/ConfigReaderTests.cs +++ b/GitVersionCore.Tests/ConfigReaderTests.cs @@ -1,4 +1,6 @@ using System.IO; +using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; [TestFixture] diff --git a/GitVersionCore/AssemblyVersioningScheme.cs b/GitVersionCore/AssemblyVersioningScheme.cs index 116c51805a..f2f061046b 100644 --- a/GitVersionCore/AssemblyVersioningScheme.cs +++ b/GitVersionCore/AssemblyVersioningScheme.cs @@ -1,6 +1,9 @@ -public enum AssemblyVersioningScheme +namespace GitVersion { - MajorMinorPatch, - MajorMinor, - Major, + public enum AssemblyVersioningScheme + { + MajorMinorPatch, + MajorMinor, + Major, + } } \ No newline at end of file diff --git a/GitVersionCore/Configuration/Config.cs b/GitVersionCore/Configuration/Config.cs index 3eaf8aeabd..587178d52b 100644 --- a/GitVersionCore/Configuration/Config.cs +++ b/GitVersionCore/Configuration/Config.cs @@ -1,4 +1,7 @@ -public class Config +namespace GitVersion.Configuration { - public AssemblyVersioningScheme AssemblyVersioningScheme { get; set; } + public class Config + { + public AssemblyVersioningScheme AssemblyVersioningScheme { get; set; } + } } \ No newline at end of file diff --git a/GitVersionCore/Configuration/ConfigReader.cs b/GitVersionCore/Configuration/ConfigReader.cs index 35fb1d921c..99a9f63cd6 100644 --- a/GitVersionCore/Configuration/ConfigReader.cs +++ b/GitVersionCore/Configuration/ConfigReader.cs @@ -2,16 +2,19 @@ using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; -public class ConfigReader +namespace GitVersion.Configuration { - public static Config Read(TextReader reader) + public class ConfigReader { - var deserializer = new Deserializer(null, new CamelCaseNamingConvention()); - var deserialize = deserializer.Deserialize(reader); - if (deserialize == null) + public static Config Read(TextReader reader) { - return new Config(); + var deserializer = new Deserializer(null, new CamelCaseNamingConvention()); + var deserialize = deserializer.Deserialize(reader); + if (deserialize == null) + { + return new Config(); + } + return deserialize; } - return deserialize; } } \ No newline at end of file diff --git a/GitVersionTask.Tests/GitVersionTask.Tests.csproj b/GitVersionTask.Tests/GitVersionTask.Tests.csproj index 4ca96a71df..bcec37cbe1 100644 --- a/GitVersionTask.Tests/GitVersionTask.Tests.csproj +++ b/GitVersionTask.Tests/GitVersionTask.Tests.csproj @@ -243,9 +243,7 @@ - - - + diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 1b62ecf360..a303579ae8 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -3,6 +3,7 @@ using System; using System.IO; using GitVersion; + using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger; @@ -85,7 +86,7 @@ AssemblyVersioningScheme GetAssemblyVersioningScheme() return ConfigReader.Read(reader).AssemblyVersioningScheme; } } - return global::AssemblyVersioningScheme.MajorMinorPatch; + return GitVersion.AssemblyVersioningScheme.MajorMinorPatch; } AssemblyVersioningScheme versioningScheme; From f8c8b38de596feff767af37c64067024e21d4cd8 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 17:19:39 +0000 Subject: [PATCH 03/17] Introduced ConfigurationProvider and added config parameter into GitVersionContext --- .../CommitCountingRepoFixture.cs | 3 ++- GitVersionCore.Tests/ConfigReaderTests.cs | 17 +++++++++--- .../EmptyRepositoryFixture.cs | 3 ++- GitVersionCore.Tests/RepositoryFixtureBase.cs | 7 +++-- GitVersionCore/Configuration/Config.cs | 15 +++++++++++ .../Configuration/ConfigurationProvider.cs | 23 ++++++++++++++++ GitVersionCore/GitVersionContext.cs | 10 ++++--- GitVersionCore/GitVersionCore.csproj | 1 + GitVersionCore/GitVersionFinder.cs | 9 +------ GitVersionExe/Program.cs | 5 +++- .../BranchFinders/DevelopTests.cs | 5 ++-- .../BranchFinders/FeatureBranchTests.cs | 9 ++++--- .../BranchFinders/PullBranchTests.cs | 7 ++--- .../BranchFinders/ReleaseTests.cs | 7 ++--- .../GitFlow/GitFlowVersionFinderTests.cs | 17 ++++++------ GitVersionTask.Tests/GitHelperTests.cs | 9 ++++--- .../MergedBranchesWithVersionFinderTests.cs | 3 ++- GitVersionTask.Tests/IntegrationTests.cs | 23 ++++++++-------- .../VersionAndBranchFinderTests.cs | 5 ++-- .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 26 +++++++------------ GitVersionTask/GetVersion.cs | 5 +++- GitVersionTask/VersionAndBranchFinder.cs | 5 ++-- GitVersionTask/VersionCache.cs | 14 +++++----- GitVersionTask/WriteVersionInfoToBuildLog.cs | 5 +++- 24 files changed, 146 insertions(+), 87 deletions(-) create mode 100644 GitVersionCore/Configuration/ConfigurationProvider.cs diff --git a/GitVersionCore.Tests/CommitCountingRepoFixture.cs b/GitVersionCore.Tests/CommitCountingRepoFixture.cs index 2c09f817ef..3e798a6aa4 100644 --- a/GitVersionCore.Tests/CommitCountingRepoFixture.cs +++ b/GitVersionCore.Tests/CommitCountingRepoFixture.cs @@ -1,11 +1,12 @@ using System; using System.IO; +using GitVersion.Configuration; using LibGit2Sharp; public class CommitCountingRepoFixture : RepositoryFixtureBase { public CommitCountingRepoFixture() : - base(CloneTestRepo) + base(CloneTestRepo, new Config()) { } diff --git a/GitVersionCore.Tests/ConfigReaderTests.cs b/GitVersionCore.Tests/ConfigReaderTests.cs index 2dd6c422f2..7b964d1040 100644 --- a/GitVersionCore.Tests/ConfigReaderTests.cs +++ b/GitVersionCore.Tests/ConfigReaderTests.cs @@ -2,6 +2,7 @@ using GitVersion; using GitVersion.Configuration; using NUnit.Framework; +using Shouldly; [TestFixture] public class ConfigReaderTests @@ -10,16 +11,24 @@ public class ConfigReaderTests [Test] public void CanReadDocument() { - var text = "assemblyVersioningScheme: MajorMinor"; + const string text = @" +assemblyVersioningScheme: MajorMinor +develop-branch-tag: alpha +release-branch-tag: rc +"; var config = ConfigReader.Read(new StringReader(text)); - Assert.AreEqual(AssemblyVersioningScheme.MajorMinor, config.AssemblyVersioningScheme); + config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinor); + config.DevelopBranchTag.ShouldBe("alpha"); + config.ReleaseBranchTag.ShouldBe("rc"); } [Test] public void CanReadDefaultDocument() { - var text = ""; + const string text = ""; var config = ConfigReader.Read(new StringReader(text)); - Assert.AreEqual(AssemblyVersioningScheme.MajorMinorPatch, config.AssemblyVersioningScheme); + config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch); + config.DevelopBranchTag.ShouldBe("unstable"); + config.ReleaseBranchTag.ShouldBe("beta"); } } \ No newline at end of file diff --git a/GitVersionCore.Tests/EmptyRepositoryFixture.cs b/GitVersionCore.Tests/EmptyRepositoryFixture.cs index 0f1e9df42f..a4ef17faff 100644 --- a/GitVersionCore.Tests/EmptyRepositoryFixture.cs +++ b/GitVersionCore.Tests/EmptyRepositoryFixture.cs @@ -1,10 +1,11 @@ using System; +using GitVersion.Configuration; using LibGit2Sharp; public class EmptyRepositoryFixture : RepositoryFixtureBase { public EmptyRepositoryFixture() : - base(CreateNewRepository) + base(CreateNewRepository, new Config()) { } diff --git a/GitVersionCore.Tests/RepositoryFixtureBase.cs b/GitVersionCore.Tests/RepositoryFixtureBase.cs index adde94dc4b..62c37167d2 100644 --- a/GitVersionCore.Tests/RepositoryFixtureBase.cs +++ b/GitVersionCore.Tests/RepositoryFixtureBase.cs @@ -1,5 +1,6 @@ using System; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using Shouldly; @@ -7,9 +8,11 @@ public abstract class RepositoryFixtureBase : IDisposable { public string RepositoryPath; public IRepository Repository; + Config configuration; - protected RepositoryFixtureBase(Func repoBuilder) + protected RepositoryFixtureBase(Func repoBuilder, Config configuration) { + this.configuration = configuration; RepositoryPath = PathHelper.GetTempPath(); Repository = repoBuilder(RepositoryPath); Repository.Config.Set("user.name", "Test"); @@ -19,7 +22,7 @@ protected RepositoryFixtureBase(Func repoBuilder) public SemanticVersion ExecuteGitVersion() { var vf = new GitVersionFinder(); - return vf.FindVersion(new GitVersionContext(Repository)); + return vf.FindVersion(new GitVersionContext(Repository, configuration)); } public void AssertFullSemver(string fullSemver) diff --git a/GitVersionCore/Configuration/Config.cs b/GitVersionCore/Configuration/Config.cs index 587178d52b..6dd9eb5073 100644 --- a/GitVersionCore/Configuration/Config.cs +++ b/GitVersionCore/Configuration/Config.cs @@ -1,7 +1,22 @@ namespace GitVersion.Configuration { + using YamlDotNet.Serialization; + public class Config { + public Config() + { + AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch; + DevelopBranchTag = "unstable"; + ReleaseBranchTag = "beta"; + } + public AssemblyVersioningScheme AssemblyVersioningScheme { get; set; } + + [YamlAlias("develop-branch-tag")] + public string DevelopBranchTag { get; set; } + + [YamlAlias("release-branch-tag")] + public string ReleaseBranchTag { get; set; } } } \ No newline at end of file diff --git a/GitVersionCore/Configuration/ConfigurationProvider.cs b/GitVersionCore/Configuration/ConfigurationProvider.cs new file mode 100644 index 0000000000..0717b7ecf1 --- /dev/null +++ b/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -0,0 +1,23 @@ +namespace GitVersion.Configuration +{ + using System.IO; + + public class ConfigurationProvider + { + public static Config Provide(string gitDirectory) + { + var configFilePath = Path.Combine(Directory.GetParent(gitDirectory).FullName, "GitVersionConfig.yaml"); + if (File.Exists(configFilePath)) + { + using (var reader = File.OpenText(configFilePath)) + { + { + return ConfigReader.Read(reader); + } + } + } + + return new Config(); + } + } +} \ No newline at end of file diff --git a/GitVersionCore/GitVersionContext.cs b/GitVersionCore/GitVersionContext.cs index 64fccaadf3..41375117d1 100644 --- a/GitVersionCore/GitVersionContext.cs +++ b/GitVersionCore/GitVersionContext.cs @@ -2,6 +2,7 @@ { using System.Collections.Generic; using System.Linq; + using GitVersion.Configuration; using LibGit2Sharp; /// @@ -9,14 +10,16 @@ /// public class GitVersionContext { - public GitVersionContext(IRepository repository) - : this(repository, repository.Head) + public GitVersionContext(IRepository repository, Config configuration) + : this(repository, repository.Head, configuration) { + Configuration = configuration; } - public GitVersionContext(IRepository repository, Branch currentBranch) + public GitVersionContext(IRepository repository, Branch currentBranch, Config configuration) { Repository = repository; + Configuration = configuration; if (currentBranch == null) return; @@ -33,6 +36,7 @@ public GitVersionContext(IRepository repository, Branch currentBranch) } } + public Config Configuration { get; private set; } public IRepository Repository { get; private set; } public Branch CurrentBranch { get; private set; } public Commit CurrentCommit { get; private set; } diff --git a/GitVersionCore/GitVersionCore.csproj b/GitVersionCore/GitVersionCore.csproj index 5530593de3..7674295956 100644 --- a/GitVersionCore/GitVersionCore.csproj +++ b/GitVersionCore/GitVersionCore.csproj @@ -70,6 +70,7 @@ + diff --git a/GitVersionCore/GitVersionFinder.cs b/GitVersionCore/GitVersionFinder.cs index dacd80ef95..418c934ec7 100644 --- a/GitVersionCore/GitVersionFinder.cs +++ b/GitVersionCore/GitVersionFinder.cs @@ -7,6 +7,7 @@ public class GitVersionFinder { public SemanticVersion FindVersion(GitVersionContext context) { + Logger.WriteInfo("Running against branch: " + context.CurrentBranch.Name); EnsureMainTopologyConstraints(context); if (ShouldGitHubFlowVersioningSchemeApply(context.Repository)) @@ -19,14 +20,6 @@ public SemanticVersion FindVersion(GitVersionContext context) return new GitFlowVersionFinder().FindVersion(context); } - public static SemanticVersion GetSemanticVersion(Repository repository) - { - var versionForRepositoryFinder = new GitVersionFinder(); - var gitVersionContext = new GitVersionContext(repository); - Logger.WriteInfo("Running against branch: " + gitVersionContext.CurrentBranch.Name); - return versionForRepositoryFinder.FindVersion(gitVersionContext); - } - static bool ShouldGitHubFlowVersioningSchemeApply(IRepository repo) { return repo.FindBranch("develop") == null; diff --git a/GitVersionExe/Program.cs b/GitVersionExe/Program.cs index 0c7f31f531..925537841f 100644 --- a/GitVersionExe/Program.cs +++ b/GitVersionExe/Program.cs @@ -6,6 +6,7 @@ namespace GitVersion using System.IO; using System.Linq; using System.Text; + using GitVersion.Configuration; class Program { @@ -78,9 +79,11 @@ static int Run() buildServer.PerformPreProcessingSteps(gitDirectory); } SemanticVersion semanticVersion; + var versionFinder = new GitVersionFinder(); using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { - semanticVersion = GitVersionFinder.GetSemanticVersion(repo); + var gitVersionContext = new GitVersionContext(repo, ConfigurationProvider.Provide(gitDirectory)); + semanticVersion = versionFinder.FindVersion(gitVersionContext); } if (arguments.Output == OutputType.BuildServer) diff --git a/GitVersionTask.Tests/BranchFinders/DevelopTests.cs b/GitVersionTask.Tests/BranchFinders/DevelopTests.cs index 272f949797..d5a8ca77b8 100644 --- a/GitVersionTask.Tests/BranchFinders/DevelopTests.cs +++ b/GitVersionTask.Tests/BranchFinders/DevelopTests.cs @@ -1,6 +1,7 @@ using FluentDate; using FluentDateTimeOffset; using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; using ObjectApproval; @@ -35,7 +36,7 @@ public void Commit_on_develop_and_previous_commit_on_master_is_a_hotfix() mockBranch }, }; - var version = finder.FindVersion(new GitVersionContext(repository, mockBranch)); + var version = finder.FindVersion(new GitVersionContext(repository, mockBranch, new Config())); Assert.AreEqual(2, version.Minor, "Minor should be master.Minor+1"); ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber); } @@ -76,7 +77,7 @@ public void Commit_on_develop_and_previous_commit_on_master_has_a_tag() } } }; - var context = new GitVersionContext(repository, develop); + var context = new GitVersionContext(repository, develop, new Config()); var version = finder.FindVersion(context); Assert.AreEqual(2, version.Minor, "Minor should be master.Minor+1"); diff --git a/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs b/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs index bf53eb3acc..cf2329dfc1 100644 --- a/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs +++ b/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs @@ -1,4 +1,5 @@ using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; @@ -20,7 +21,7 @@ public void Feature_branch_with_no_commit() var finder = new FeatureVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, featureBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, featureBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); @@ -45,7 +46,7 @@ public void Feature_branch_with_1_commit() var finder = new FeatureVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, featureBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, featureBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); @@ -73,7 +74,7 @@ public void Feature_branch_with_2_commits() var finder = new FeatureVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, featureBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, featureBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); @@ -100,7 +101,7 @@ public void Feature_branch_with_2_commits_but_building_an_commit() var finder = new FeatureVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, featureBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, featureBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); diff --git a/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs b/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs index a3886bd4e6..2a8f214b76 100644 --- a/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs +++ b/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs @@ -1,4 +1,5 @@ using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; @@ -35,7 +36,7 @@ void AssertInvalidPullBranchName(string invalidFakePullBranchName) var finder = new PullVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, pullBranch))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, pullBranch, new Config()))); } } @@ -54,7 +55,7 @@ public void Pull_branch_with_1_commit() var finder = new PullVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, pullBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, pullBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); @@ -80,7 +81,7 @@ public void Pull_branch_with_2_commits() var finder = new PullVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, pullBranch)); + var version = finder.FindVersion(new GitVersionContext(repo, pullBranch, new Config())); var masterVersion = FindersHelper.RetrieveMasterVersion(repo); diff --git a/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs b/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs index 3bf3d6e506..c3e2054589 100644 --- a/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs +++ b/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs @@ -1,5 +1,6 @@ using System; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; @@ -20,7 +21,7 @@ public void EnsureAReleaseBranchNameDoesNotExposeAPatchSegment() var finder = new ReleaseVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, releaseBranch))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, releaseBranch, new Config()))); } } @@ -37,7 +38,7 @@ public void EnsureAReleaseBranchNameDoesNotExposeAStability() var finder = new ReleaseVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, releaseBranch))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, releaseBranch, new Config()))); } } @@ -55,7 +56,7 @@ public void Tag_on_commit_should_be_exact_tag() var finder = new ReleaseVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repo, repo.Head)); + var version = finder.FindVersion(new GitVersionContext(repo, repo.Head, new Config())); ObjectApprover.VerifyWithJson(version, Scrubbers.GuidAndDateScrubber); } } diff --git a/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs b/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs index 205ed60b95..05f1a2b48b 100644 --- a/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs +++ b/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs @@ -1,5 +1,6 @@ using System.IO; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; @@ -19,7 +20,7 @@ public void RequiresALocalMasterBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, new Config()))); } } @@ -35,7 +36,7 @@ public void RequiresALocalDevelopBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, new Config()))); } } @@ -56,7 +57,7 @@ public void AFeatureBranchIsRequiredToBranchOffOfDevelopBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature, new Config()))); } } @@ -77,7 +78,7 @@ public void AHotfixBranchIsRequiredToBranchOffOfMasterBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature, new Config()))); } } @@ -98,7 +99,7 @@ public void APullRequestBranchIsRequiredToBranchOffOfDevelopBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, pull))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, pull, new Config()))); } } @@ -117,7 +118,7 @@ public void AFeatureBranchDoesNotRequireASpecificPrefix() var finder = new GitVersionFinder(); - var versionAndBranch = finder.FindVersion(new GitVersionContext(repo)); + var versionAndBranch = finder.FindVersion(new GitVersionContext(repo, new Config())); ObjectApprover.VerifyWithJson(versionAndBranch, Scrubbers.GuidAndDateScrubber); } @@ -138,7 +139,7 @@ public void AFeatureBranchPrefixIsNotIncludedInTag() var finder = new GitVersionFinder(); - var versionAndBranch = finder.FindVersion(new GitVersionContext(repo)); + var versionAndBranch = finder.FindVersion(new GitVersionContext(repo, new Config())); ObjectApprover.VerifyWithJson(versionAndBranch, Scrubbers.GuidAndDateScrubber); } @@ -166,7 +167,7 @@ public void AReleaseBranchIsRequiredToBranchOffOfDevelopBranch() var finder = new GitVersionFinder(); - Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature))); + Assert.Throws(() => finder.FindVersion(new GitVersionContext(repo, feature, new Config()))); } } } \ No newline at end of file diff --git a/GitVersionTask.Tests/GitHelperTests.cs b/GitVersionTask.Tests/GitHelperTests.cs index f284c1f81f..01b91e007a 100644 --- a/GitVersionTask.Tests/GitHelperTests.cs +++ b/GitVersionTask.Tests/GitHelperTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Linq; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; @@ -17,7 +18,7 @@ public void CanDetermineTheVersionFromAFetchedMaster() using (var repository = new Repository(gitDirectory)) { - var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository)); + var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository, new Config())); Assert.IsNotNull(semanticVersion); } } @@ -35,7 +36,7 @@ public void CanDetermineTheVersionFromAPullRequest() using (var repository = new Repository(gitDirectory)) { - var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository)); + var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository, new Config())); Assert.IsNotNull(semanticVersion); } } @@ -50,7 +51,7 @@ public void CanDetermineTheVersionFromAFetchedDevelop() using (var repository = new Repository(gitDirectory)) { - var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository)); + var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository, new Config())); Assert.IsNotNull(semanticVersion); } } @@ -65,7 +66,7 @@ public void CanDetermineTheVersionFromAFetchedFeature() using (var repository = new Repository(gitDirectory)) { - var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository)); + var semanticVersion = new GitVersionFinder().FindVersion(new GitVersionContext(repository, new Config())); Assert.IsNotNull(semanticVersion); } } diff --git a/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs b/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs index 976d8b6af9..b9cf088f41 100644 --- a/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs +++ b/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs @@ -1,4 +1,5 @@ using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; using Shouldly; @@ -16,7 +17,7 @@ public void ShouldFindMergeCommit() MessageEx = "Merge branch 'release-2.0.0'" } }; - var sut = new MergedBranchesWithVersionFinder(new GitVersionContext(null, currentBranch)); + var sut = new MergedBranchesWithVersionFinder(new GitVersionContext(null, currentBranch, new Config())); SemanticVersion version; sut.TryGetVersion(out version); diff --git a/GitVersionTask.Tests/IntegrationTests.cs b/GitVersionTask.Tests/IntegrationTests.cs index 6145df1054..1da79ce2cf 100644 --- a/GitVersionTask.Tests/IntegrationTests.cs +++ b/GitVersionTask.Tests/IntegrationTests.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Linq; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; @@ -35,7 +36,7 @@ public void TimingOnNSB() var branch = repository.Branches.First(x => x.Name == "develop"); var finder = new GitVersionFinder(); - finder.FindVersion(new GitVersionContext(repository, branch)); + finder.FindVersion(new GitVersionContext(repository, branch, new Config())); } Debug.WriteLine(startNew.ElapsedMilliseconds); startNew = Stopwatch.StartNew(); @@ -44,7 +45,7 @@ public void TimingOnNSB() var branch = repository.Branches.First(x => x.Name == "develop"); var finder = new GitVersionFinder(); - finder.FindVersion(new GitVersionContext(repository, branch)); + finder.FindVersion(new GitVersionContext(repository, branch, new Config())); } Debug.WriteLine(startNew.ElapsedMilliseconds); } @@ -68,7 +69,7 @@ public void NServiceBusRelease() var branch = repository.Branches.First(x => x.Name == "release-4.1.0"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -86,7 +87,7 @@ public void NServiceBusReleaseSpecificCommit() repository.Checkout("c0e0a5e13775552cd3e08e039f453e4cf1fd4235"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -103,7 +104,7 @@ public void NServiceBusHotfix() var branch = repository.Branches.First(x => x.Name == "hotfix-4.1.1"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -120,7 +121,7 @@ public void NServiceBusMaster() var branch = repository.Branches.First(x => x.Name == "master"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -137,7 +138,7 @@ public void NServiceBusDevelop() var branch = repository.Branches.First(x => x.Name == "develop"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -154,7 +155,7 @@ public void NServiceBusHead() var branch = repository.Head; var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -184,7 +185,7 @@ public void NServiceBusDevelopOlderCommit() repository.Checkout("c0e0a5e13775552cd3e08e039f453e4cf1fd4235"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -201,7 +202,7 @@ public void Foo() var branch = repository.Branches.First(x => x.Name == "develop"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); @@ -217,7 +218,7 @@ public void NServiceBusNhibernate() var branch = repository.FindBranch("develop"); var finder = new GitVersionFinder(); - var version = finder.FindVersion(new GitVersionContext(repository, branch)); + var version = finder.FindVersion(new GitVersionContext(repository, branch, new Config())); Debug.WriteLine(version.Major); Debug.WriteLine(version.Minor); Debug.WriteLine(version.Patch); diff --git a/GitVersionTask.Tests/VersionAndBranchFinderTests.cs b/GitVersionTask.Tests/VersionAndBranchFinderTests.cs index 35d8fcf801..0b48038001 100644 --- a/GitVersionTask.Tests/VersionAndBranchFinderTests.cs +++ b/GitVersionTask.Tests/VersionAndBranchFinderTests.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -17,7 +18,7 @@ public void ShouldBeAbleGetVersionFromGitDir() } CachedVersion versionAndBranch; - VersionAndBranchFinder.TryGetVersion(ASBMTestRepoWorkingDirPath, out versionAndBranch); + VersionAndBranchFinder.TryGetVersion(ASBMTestRepoWorkingDirPath, out versionAndBranch, new Config()); Assert.IsNotNull(versionAndBranch); } } diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index a303579ae8..800e68e251 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -63,30 +63,22 @@ public void InnerExecute() InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile); + var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); + var config = ConfigurationProvider.Provide(gitDirectory); + CachedVersion semanticVersion; - if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion)) + if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) { return; } - - CreateTempAssemblyInfo(semanticVersion); + CreateTempAssemblyInfo(semanticVersion, config); } - AssemblyVersioningScheme GetAssemblyVersioningScheme() + AssemblyVersioningScheme GetAssemblyVersioningScheme(Config config) { if (string.IsNullOrWhiteSpace(AssemblyVersioningScheme)) { - var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); - - var configFilePath = Path.Combine(Directory.GetParent(gitDirectory).FullName, "GitVersionConfig.yaml"); - if (File.Exists(configFilePath)) - { - using (var reader = File.OpenText(configFilePath)) - { - return ConfigReader.Read(reader).AssemblyVersioningScheme; - } - } - return GitVersion.AssemblyVersioningScheme.MajorMinorPatch; + return config.AssemblyVersioningScheme; } AssemblyVersioningScheme versioningScheme; @@ -99,9 +91,9 @@ AssemblyVersioningScheme GetAssemblyVersioningScheme() throw new WarningException(string.Format("Unexpected assembly versioning scheme '{0}'.", AssemblyVersioningScheme)); } - void CreateTempAssemblyInfo(CachedVersion semanticVersion) + void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config config) { - var versioningScheme = GetAssemblyVersioningScheme(); + var versioningScheme = GetAssemblyVersioningScheme(config); var assemblyInfoBuilder = new AssemblyInfoBuilder { CachedVersion = semanticVersion, diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index 5e41ceeefa..00f865498a 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -2,6 +2,7 @@ { using System; using GitVersion; + using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger; @@ -85,7 +86,9 @@ public override bool Execute() try { CachedVersion versionAndBranch; - if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch)) + var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); + var config = ConfigurationProvider.Provide(gitDirectory); + if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, config)) { var thisType = typeof(GetVersion); var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion); diff --git a/GitVersionTask/VersionAndBranchFinder.cs b/GitVersionTask/VersionAndBranchFinder.cs index 013ba7afb7..1f70ef8de4 100644 --- a/GitVersionTask/VersionAndBranchFinder.cs +++ b/GitVersionTask/VersionAndBranchFinder.cs @@ -1,10 +1,11 @@ using System.Collections.Generic; using GitVersion; +using GitVersion.Configuration; public static class VersionAndBranchFinder { static List processedDirectories = new List(); - public static bool TryGetVersion(string directory, out CachedVersion versionAndBranch) + public static bool TryGetVersion(string directory, out CachedVersion versionAndBranch, Config configuration) { var gitDirectory = GitDirFinder.TreeWalkForGitDir(directory); @@ -30,7 +31,7 @@ public static bool TryGetVersion(string directory, out CachedVersion versionAndB buildServer.PerformPreProcessingSteps(gitDirectory); } } - versionAndBranch = VersionCache.GetVersion(gitDirectory); + versionAndBranch = VersionCache.GetVersion(gitDirectory, configuration); return true; } } diff --git a/GitVersionTask/VersionCache.cs b/GitVersionTask/VersionCache.cs index f2a38fcb1a..d36460f52d 100644 --- a/GitVersionTask/VersionCache.cs +++ b/GitVersionTask/VersionCache.cs @@ -1,14 +1,17 @@ using System.Collections.Generic; using GitVersion; +using GitVersion.Configuration; public static class VersionCache { static Dictionary versionCacheVersions = new Dictionary(); - public static CachedVersion GetVersion(string gitDirectory) + public static CachedVersion GetVersion(string gitDirectory, Config configuration) { using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { + var versionFinder = new GitVersionFinder(); + var context = new GitVersionContext(repo, configuration); var ticks = DirectoryDateFinder.GetLastDirectoryWrite(gitDirectory); var key = string.Format("{0}:{1}:{2}", repo.Head.CanonicalName, repo.Head.Tip.Sha, ticks); CachedVersion cachedVersion; @@ -17,21 +20,16 @@ public static CachedVersion GetVersion(string gitDirectory) if (cachedVersion.Timestamp != ticks) { Logger.WriteInfo("Change detected. flushing cache."); - cachedVersion.SemanticVersion = GitVersionFinder.GetSemanticVersion(repo); + cachedVersion.SemanticVersion = versionFinder.FindVersion(context); cachedVersion.MasterReleaseDate = LastMinorVersionFinder.Execute(repo, repo.Head.Tip); } return cachedVersion; } Logger.WriteInfo("Version not in cache. Calculating version."); - //TODO: cope with githubflow - //if (GitVersionFinder.ShouldGitHubFlowVersioningSchemeApply(repo)) - //{ - // return rd; - //} return versionCacheVersions[key] = new CachedVersion { - SemanticVersion = GitVersionFinder.GetSemanticVersion(repo), + SemanticVersion = versionFinder.FindVersion(context), MasterReleaseDate = LastMinorVersionFinder.Execute(repo,repo.Head.Tip), Timestamp = ticks }; diff --git a/GitVersionTask/WriteVersionInfoToBuildLog.cs b/GitVersionTask/WriteVersionInfoToBuildLog.cs index efd83b9731..7d4a57c4cc 100644 --- a/GitVersionTask/WriteVersionInfoToBuildLog.cs +++ b/GitVersionTask/WriteVersionInfoToBuildLog.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using GitVersion; + using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger; @@ -47,7 +48,9 @@ public override bool Execute() public void InnerExecute() { CachedVersion semanticVersion; - if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion)) + var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); + var config = ConfigurationProvider.Provide(gitDirectory); + if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) { return; } From 42e470f1bc537b19d0d4a2536625f81f7f52c117 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 21:34:08 +0000 Subject: [PATCH 04/17] Fixed busted test --- .../GitVersionCore.Tests.csproj | 68 +++++++++++++++++++ GitVersionCore/GitDirFinder.cs | 2 +- .../GitHubFlow/NextVersionTxtFileFinder.cs | 3 +- .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 3 + 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj index dad7c23e8d..bd59df0ce9 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -93,6 +93,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103,6 +167,10 @@ + + + + diff --git a/GitVersionCore/GitDirFinder.cs b/GitVersionCore/GitDirFinder.cs index 10fadaa497..af0de4a893 100644 --- a/GitVersionCore/GitDirFinder.cs +++ b/GitVersionCore/GitDirFinder.cs @@ -11,7 +11,7 @@ public static string TreeWalkForGitDir(string currentDirectory) if (gitDirectory != null) { - return gitDirectory.TrimEnd(new []{ Path.DirectorySeparatorChar }); + return gitDirectory.TrimEnd(Path.DirectorySeparatorChar); } return null; diff --git a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs index e36ea77cdc..49b2b6077f 100644 --- a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs +++ b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs @@ -33,8 +33,7 @@ public bool TryGetNextVersion(out SemanticVersion semanticVersion) throw new ArgumentException("Make sure you have a valid semantic version in NextVersion.txt"); } - - return true; + return true; } } } \ No newline at end of file diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 800e68e251..4b9e67037e 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -64,6 +64,9 @@ public void InnerExecute() InvalidFileChecker.CheckForInvalidFiles(CompileFiles, ProjectFile); var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); + if (string.IsNullOrEmpty(gitDirectory)) + return; + var config = ConfigurationProvider.Provide(gitDirectory); CachedVersion semanticVersion; From 08af262a627c3115fc307b5b89a9d4ed3b19e673 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 22:05:11 +0000 Subject: [PATCH 05/17] Promoted config up in tests --- .../EmptyRepositoryFixture.cs | 4 ++-- .../GitFlow/BaseGitFlowRepositoryFixture.cs | 5 +++-- .../GitFlow/DevelopScenarios.cs | 7 ++++--- GitVersionCore.Tests/GitFlow/WikiScenarios.cs | 5 +++-- .../GitHubFlow/MasterTests.cs | 21 ++++++++++--------- .../GitHubFlow/OtherBranchTests.cs | 5 +++-- .../GitHubFlow/ReleaseBranchTests.cs | 9 ++++---- .../LastVersionOnMasterFinderTests.cs | 9 ++++---- .../BranchFinders/DevelopVersionFinder.cs | 2 +- .../ExecCmdLineArgumentTest.cs | 5 +++-- GitVersionExe.Tests/MsBuildProjectArgTest.cs | 3 ++- .../PullRequestInTeamCityTest.cs | 3 ++- 12 files changed, 44 insertions(+), 34 deletions(-) diff --git a/GitVersionCore.Tests/EmptyRepositoryFixture.cs b/GitVersionCore.Tests/EmptyRepositoryFixture.cs index a4ef17faff..57751e8e5c 100644 --- a/GitVersionCore.Tests/EmptyRepositoryFixture.cs +++ b/GitVersionCore.Tests/EmptyRepositoryFixture.cs @@ -4,8 +4,8 @@ public class EmptyRepositoryFixture : RepositoryFixtureBase { - public EmptyRepositoryFixture() : - base(CreateNewRepository, new Config()) + public EmptyRepositoryFixture(Config config) : + base(CreateNewRepository, config) { } diff --git a/GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs b/GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs index b477907384..c911c3b196 100644 --- a/GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs +++ b/GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs @@ -1,15 +1,16 @@ using System; using System.IO; +using GitVersion.Configuration; using LibGit2Sharp; public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture { - public BaseGitFlowRepositoryFixture(string initialVersion) + public BaseGitFlowRepositoryFixture(string initialVersion) : base(new Config()) { SetupRepo(r => r.MakeATaggedCommit(initialVersion)); } - public BaseGitFlowRepositoryFixture(Action initialMasterAction) + public BaseGitFlowRepositoryFixture(Action initialMasterAction) : base(new Config()) { SetupRepo(initialMasterAction); } diff --git a/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs b/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs index 6c18c078eb..88af1d6ae2 100644 --- a/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs +++ b/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -7,7 +8,7 @@ public class DevelopScenarios [Test] public void WhenDevelopBranchedFromMaster_MinorIsIncreased() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.0.0"); fixture.Repository.CreateBranch("develop").Checkout(); @@ -18,7 +19,7 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased() [Test] public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.0.0"); fixture.Repository.CreateBranch("develop").Checkout(); diff --git a/GitVersionCore.Tests/GitFlow/WikiScenarios.cs b/GitVersionCore.Tests/GitFlow/WikiScenarios.cs index 847c0fe0d9..bdb3e6bc01 100644 --- a/GitVersionCore.Tests/GitFlow/WikiScenarios.cs +++ b/GitVersionCore.Tests/GitFlow/WikiScenarios.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -37,7 +38,7 @@ participant release-1.3.0 [Test] public void MinorReleaseExample() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.2.0"); diff --git a/GitVersionCore.Tests/GitHubFlow/MasterTests.cs b/GitVersionCore.Tests/GitHubFlow/MasterTests.cs index de3575e19c..61858ca7df 100644 --- a/GitVersionCore.Tests/GitHubFlow/MasterTests.cs +++ b/GitVersionCore.Tests/GitHubFlow/MasterTests.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -7,7 +8,7 @@ public class MasterTests [Test] public void GivenARepositoryWithCommitsButNoTags_VersionShouldBe_0_1() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { // Given fixture.Repository.MakeACommit(); @@ -22,7 +23,7 @@ public void GivenARepositoryWithCommitsButNoTags_VersionShouldBe_0_1() [Test] public void GivenARepositoryWithCommitsButNoTagsWithDetachedHead_VersionShouldBe_0_1() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { // Given fixture.Repository.MakeACommit(); @@ -41,7 +42,7 @@ public void GivenARepositoryWithCommitsButNoTagsWithDetachedHead_VersionShouldBe [Test] public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string ExpectedNextVersion = "1.0.0"; fixture.Repository.MakeACommit(); @@ -56,7 +57,7 @@ public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchV [Test] public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string ExpectedNextVersion = "1.1.0"; const string TaggedVersion = "1.0.3"; @@ -71,7 +72,7 @@ public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVers [Test] public void GivenARepositoryWithTagAndANextVersionTxtFileAndNoCommits_VersionShouldBeTag() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string ExpectedNextVersion = "1.1.0"; const string TaggedVersion = "1.0.3"; @@ -85,7 +86,7 @@ public void GivenARepositoryWithTagAndANextVersionTxtFileAndNoCommits_VersionSho [Test] public void GivenARepositoryWithTagAndNoNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string TaggedVersion = "1.0.3"; fixture.Repository.MakeATaggedCommit(TaggedVersion); @@ -98,7 +99,7 @@ public void GivenARepositoryWithTagAndNoNextVersionTxtFile_VersionShouldBeTagWit [Test] public void GivenARepositoryWithTagAndNoNextVersionTxtFileAndNoCommits_VersionShouldBeTag() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string TaggedVersion = "1.0.3"; fixture.Repository.MakeATaggedCommit(TaggedVersion); @@ -110,7 +111,7 @@ public void GivenARepositoryWithTagAndNoNextVersionTxtFileAndNoCommits_VersionSh [Test] public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string NextVersionTxt = "1.0.0"; const string TaggedVersion = "1.1.0"; @@ -125,7 +126,7 @@ public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWi [Test] public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionShouldBeTag() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string NextVersionTxt = "1.0.0"; const string TaggedVersion = "1.1.0"; diff --git a/GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs b/GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs index 08df26c60d..58973bb241 100644 --- a/GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs +++ b/GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -7,7 +8,7 @@ public class OtherBranchTests [Test] public void CanTakeVersionFromReleaseBranch() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string TaggedVersion = "1.0.3"; fixture.Repository.MakeATaggedCommit(TaggedVersion); diff --git a/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs index 3ae1a23e4f..a39220d3ab 100644 --- a/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs +++ b/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs @@ -1,4 +1,5 @@ -using LibGit2Sharp; +using GitVersion.Configuration; +using LibGit2Sharp; using NUnit.Framework; [TestFixture] @@ -7,7 +8,7 @@ public class ReleaseBranchTests [Test] public void CanTakeVersionFromReleaseBranch() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.0.3"); fixture.Repository.MakeCommits(5); @@ -21,7 +22,7 @@ public void CanTakeVersionFromReleaseBranch() [Test] public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.0.3"); fixture.Repository.MakeCommits(1); @@ -37,7 +38,7 @@ public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt() [Test] public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.0.3"); fixture.Repository.MakeCommits(1); diff --git a/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs b/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs index 5b8f55da35..60eeeb8de8 100644 --- a/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs +++ b/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs @@ -1,5 +1,6 @@ using System; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using Shouldly; @@ -11,7 +12,7 @@ public class LastVersionOnMasterFinderTests [Test] public void WhenMasterHasPatchTagEnsureLastMinorTagIsUsed() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { var stamp = new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero); fixture.Repository.MakeACommit(stamp); @@ -28,7 +29,7 @@ public void WhenMasterHasPatchTagEnsureLastMinorTagIsUsed() [Test] public void WhenNoTagsOrMergeCommitsShouldUseFirstCommit() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { var stamp = new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero); fixture.Repository.MakeACommit(stamp); @@ -40,7 +41,7 @@ public void WhenNoTagsOrMergeCommitsShouldUseFirstCommit() [Test] public void WhenSupportIsBranchedFromMasterEnsureLastMinorTagIsUsed() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { var stamp = new DateTimeOffset(2000, 1, 1, 1, 1, 1, TimeSpan.Zero); fixture.Repository.MakeACommit(stamp); @@ -57,7 +58,7 @@ public void WhenSupportIsBranchedFromMasterEnsureLastMinorTagIsUsed() [Test] public void WhenSupportIsBranchedAndTaggedFromAnotherSupportEnsureNewMinorIsUsed() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeACommit(); fixture.Repository.CreateBranch("Support-1.2.0"); diff --git a/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs index 9f6a1e80f3..c704f924fa 100644 --- a/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs @@ -26,7 +26,7 @@ public SemanticVersion FindVersion(GitVersionContext context) Major = versionFromMaster.Major, Minor = versionFromMaster.Minor + 1, Patch = 0, - PreReleaseTag = "unstable" + numberOfCommitsSinceRelease, + PreReleaseTag = context.Configuration.DevelopBranchTag + numberOfCommitsSinceRelease, BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name,tip.Sha,tip.When()), }; diff --git a/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs b/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs index de1a2f4367..cd9713fad0 100644 --- a/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs +++ b/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs @@ -1,4 +1,5 @@ using System.IO; +using GitVersion.Configuration; using NUnit.Framework; using Shouldly; @@ -10,7 +11,7 @@ public class ExecCmdLineArgumentTest [Test] public void RunExecViaCommandLine() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.2.3"); fixture.Repository.MakeACommit(); @@ -34,7 +35,7 @@ public void RunExecViaCommandLine() [Test] public void InvalidArgumentsExitCodeShouldNotBeZero() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit("1.2.3"); fixture.Repository.MakeACommit(); diff --git a/GitVersionExe.Tests/MsBuildProjectArgTest.cs b/GitVersionExe.Tests/MsBuildProjectArgTest.cs index 6cd2bec0b1..c21b08c928 100644 --- a/GitVersionExe.Tests/MsBuildProjectArgTest.cs +++ b/GitVersionExe.Tests/MsBuildProjectArgTest.cs @@ -1,4 +1,5 @@ using System.IO; +using GitVersion.Configuration; using NUnit.Framework; using Shouldly; @@ -9,7 +10,7 @@ public class MsBuildProjectArgTest public void RunsMsBuildProvideViaCommandLineArg() { const string TaggedVersion = "1.2.3"; - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { fixture.Repository.MakeATaggedCommit(TaggedVersion); diff --git a/GitVersionExe.Tests/PullRequestInTeamCityTest.cs b/GitVersionExe.Tests/PullRequestInTeamCityTest.cs index acea7306ca..15fdc1733b 100644 --- a/GitVersionExe.Tests/PullRequestInTeamCityTest.cs +++ b/GitVersionExe.Tests/PullRequestInTeamCityTest.cs @@ -1,5 +1,6 @@ using System; using GitVersion; +using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using Shouldly; @@ -12,7 +13,7 @@ public class PullRequestInTeamCityTest [TestCase("refs/pull/5/merge")] public void GivenARemoteWithATagOnMaster_AndAPullRequestWithTwoCommits_AndBuildIsRunningInTeamCity_VersionIsCalculatedProperly(string pullRequestRef) { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { var remoteRepositoryPath = PathHelper.GetTempPath(); Repository.Init(remoteRepositoryPath); From 1389f814c92933f98cf1e2287665fdeae8d06976 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 22:05:39 +0000 Subject: [PATCH 06/17] Added tests for overriding develop tag via config and updated msbuild Tasks --- .../GitFlow/DevelopScenarios.cs | 28 +++++++++++++++++ .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 31 +++++++++++++++++-- GitVersionTask/GetVersion.cs | 17 ++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs b/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs index 88af1d6ae2..6f89553ad5 100644 --- a/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs +++ b/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs @@ -15,6 +15,34 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased() fixture.AssertFullSemver("1.1.0-unstable.0+0"); } } + + [Test] + public void CanChangeDevelopTagViaConfig() + { + using (var fixture = new EmptyRepositoryFixture(new Config + { + DevelopBranchTag = "alpha" + })) + { + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.CreateBranch("develop").Checkout(); + fixture.AssertFullSemver("1.1.0-alpha.0+0"); + } + } + + [Test] + public void CanClearDevelopTagViaConfig() + { + using (var fixture = new EmptyRepositoryFixture(new Config + { + DevelopBranchTag = "" + })) + { + fixture.Repository.MakeATaggedCommit("1.0.0"); + fixture.Repository.CreateBranch("develop").Checkout(); + fixture.AssertFullSemver("1.1.0+0"); + } + } [Test] public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased() diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 4b9e67037e..5a4b162d66 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -12,6 +12,10 @@ public class UpdateAssemblyInfo : Task { public string AssemblyVersioningScheme { get; set; } + public string DevelopBranchTag { get; set; } + + public string ReleaseBranchTag { get; set; } + [Required] public string SolutionDirectory { get; set; } @@ -68,6 +72,30 @@ public void InnerExecute() return; var config = ConfigurationProvider.Provide(gitDirectory); + if (!string.IsNullOrEmpty(AssemblyVersioningScheme)) + { + AssemblyVersioningScheme versioningScheme; + if (Enum.TryParse(AssemblyVersioningScheme, true, out versioningScheme)) + { + config.AssemblyVersioningScheme = versioningScheme; + } + else + { + throw new WarningException(string.Format("Unexpected assembly versioning scheme '{0}'.", AssemblyVersioningScheme)); + } + } + + // TODO This should be covered by tests + // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag + if (DevelopBranchTag != null) + { + config.DevelopBranchTag = DevelopBranchTag; + } + + if (ReleaseBranchTag != null) + { + config.ReleaseBranchTag = ReleaseBranchTag; + } CachedVersion semanticVersion; if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) @@ -96,11 +124,10 @@ AssemblyVersioningScheme GetAssemblyVersioningScheme(Config config) void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config config) { - var versioningScheme = GetAssemblyVersioningScheme(config); var assemblyInfoBuilder = new AssemblyInfoBuilder { CachedVersion = semanticVersion, - AssemblyVersioningScheme = versioningScheme, + AssemblyVersioningScheme = config.AssemblyVersioningScheme, }; var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(); diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index 00f865498a..e08a43bc31 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -72,6 +72,10 @@ public class GetVersion : Task [Output] public string NuGetVersion { get; set; } + public string DevelopBranchTag { get; set; } + + public string ReleaseBranchTag { get; set; } + TaskLogger logger; public GetVersion() @@ -88,6 +92,19 @@ public override bool Execute() CachedVersion versionAndBranch; var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); var config = ConfigurationProvider.Provide(gitDirectory); + + // TODO This should be covered by tests + // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag + if (DevelopBranchTag != null) + { + config.DevelopBranchTag = DevelopBranchTag; + } + + if (ReleaseBranchTag != null) + { + config.ReleaseBranchTag = ReleaseBranchTag; + } + if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, config)) { var thisType = typeof(GetVersion); From ba66f4ea5b1abd07e4a50b3daf8e4e69ed826fb8 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 22:26:18 +0000 Subject: [PATCH 07/17] Updated support for release branch tag name configuration --- .../GitFlow/ReleaseBranchTests.cs | 86 +++++++++++++++++++ .../GitHubFlow/ReleaseBranchTests.cs | 14 +++ .../BranchFinders/ReleaseVersionFinder.cs | 2 +- .../GitHubFlow/OtherBranchVersionFinder.cs | 2 +- 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs diff --git a/GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs new file mode 100644 index 0000000000..c3625d357d --- /dev/null +++ b/GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs @@ -0,0 +1,86 @@ +using GitVersion.Configuration; +using LibGit2Sharp; +using NUnit.Framework; + +[TestFixture] +public class GitFlowReleaseBranchTests +{ + [Test] + public void CanTakeVersionFromReleaseBranch() + { + using (var fixture = new EmptyRepositoryFixture(new Config())) + { + fixture.Repository.MakeATaggedCommit("1.0.3"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.MakeCommits(5); + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + + fixture.AssertFullSemver("2.0.0-beta.1+5"); + } + } + + [Test] + public void CanTakeVersionFromReleaseBranchWithTagOverriden() + { + using (var fixture = new EmptyRepositoryFixture(new Config { ReleaseBranchTag = "rc" })) + { + fixture.Repository.MakeATaggedCommit("1.0.3"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.MakeCommits(5); + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + + fixture.AssertFullSemver("2.0.0-rc.1+5"); + } + } + + [Test] + public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt() + { + using (var fixture = new EmptyRepositoryFixture(new Config())) + { + fixture.Repository.MakeATaggedCommit("1.0.3"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.MakeCommits(1); + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + fixture.Repository.MakeCommits(4); + fixture.Repository.Checkout("master"); + fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow()); + + // TODO For GitHubFlow this is 2.0.0+6, why is it different + fixture.AssertFullSemver("2.0.0"); + } + } + + // TODO This test fails for GitFlow, it needs to be fixed (although in reality a support branch should be used) + [Test, Ignore] + public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt() + { + using (var fixture = new EmptyRepositoryFixture(new Config())) + { + fixture.Repository.MakeATaggedCommit("1.0.3"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.MakeCommits(1); + + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + fixture.Repository.MakeCommits(4); + fixture.Repository.Checkout("master"); + fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow()); + fixture.Repository.Checkout("develop"); + fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow()); + + fixture.Repository.CreateBranch("release-1.0.0"); + fixture.Repository.Checkout("release-1.0.0"); + fixture.Repository.MakeCommits(4); + fixture.Repository.Checkout("master"); + fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow()); + fixture.Repository.Checkout("develop"); + fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow()); + + fixture.AssertFullSemver("2.0.0+11"); + } + } +} \ No newline at end of file diff --git a/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs index a39220d3ab..262ffafe40 100644 --- a/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs +++ b/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs @@ -19,6 +19,20 @@ public void CanTakeVersionFromReleaseBranch() } } + [Test] + public void CanTakeVersionFromReleaseBranchWithTagOverriden() + { + using (var fixture = new EmptyRepositoryFixture(new Config { ReleaseBranchTag = "rc" })) + { + fixture.Repository.MakeATaggedCommit("1.0.3"); + fixture.Repository.MakeCommits(5); + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + + fixture.AssertFullSemver("2.0.0-rc.1+5"); + } + } + [Test] public void WhenReleaseBranchIsMergedIntoMasterVersionIsTakenWithIt() { diff --git a/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs index 3df165d776..060c6864f9 100644 --- a/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs @@ -14,7 +14,7 @@ public SemanticVersion FindVersion(GitVersionContext context) var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name)).ToList(); var numberOfCommitsSinceLastTagOrBranchPoint = BranchCommitDifferenceFinder.NumberOfCommitsSinceLastTagOrBranchPoint(context, applicableTagsInDescendingOrder, BranchType.Release, "develop"); - var semanticVersionPreReleaseTag = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, applicableTagsInDescendingOrder) ?? "beta.1"; + var semanticVersionPreReleaseTag = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, applicableTagsInDescendingOrder) ?? context.Configuration.ReleaseBranchTag + ".1"; return new SemanticVersion { diff --git a/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs b/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs index a26c670ea3..f964ffd61a 100644 --- a/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs +++ b/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs @@ -23,7 +23,7 @@ public bool FindVersion(GitVersionContext context, out SemanticVersion semanticV if (semanticVersionPreReleaseTag.Name == "release") { - semanticVersionPreReleaseTag.Name = "beta"; + semanticVersionPreReleaseTag.Name = context.Configuration.ReleaseBranchTag; } semanticVersion = new SemanticVersion From aa284e79ab9cad90931a5045746ed4b4e7683bc4 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 22:38:51 +0000 Subject: [PATCH 08/17] Moved test fixtures into their own folder --- .../BaseGitFlowRepositoryFixture.cs | 0 .../{ => Fixtures}/CommitCountingRepoFixture.cs | 0 .../{ => Fixtures}/EmptyRepositoryFixture.cs | 0 .../{ => Fixtures}/RepositoryFixtureBase.cs | 0 ...yCommitFixture.cs => MetaDataByCommitScenarios.cs} | 2 +- GitVersionCore.Tests/GitVersionCore.Tests.csproj | 11 ++++++----- 6 files changed, 7 insertions(+), 6 deletions(-) rename GitVersionCore.Tests/{GitFlow => Fixtures}/BaseGitFlowRepositoryFixture.cs (100%) rename GitVersionCore.Tests/{ => Fixtures}/CommitCountingRepoFixture.cs (100%) rename GitVersionCore.Tests/{ => Fixtures}/EmptyRepositoryFixture.cs (100%) rename GitVersionCore.Tests/{ => Fixtures}/RepositoryFixtureBase.cs (100%) rename GitVersionCore.Tests/GitFlow/{MetaDataByCommitFixture.cs => MetaDataByCommitScenarios.cs} (99%) diff --git a/GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs b/GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/BaseGitFlowRepositoryFixture.cs rename to GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs diff --git a/GitVersionCore.Tests/CommitCountingRepoFixture.cs b/GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs similarity index 100% rename from GitVersionCore.Tests/CommitCountingRepoFixture.cs rename to GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs diff --git a/GitVersionCore.Tests/EmptyRepositoryFixture.cs b/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs similarity index 100% rename from GitVersionCore.Tests/EmptyRepositoryFixture.cs rename to GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs diff --git a/GitVersionCore.Tests/RepositoryFixtureBase.cs b/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs similarity index 100% rename from GitVersionCore.Tests/RepositoryFixtureBase.cs rename to GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs diff --git a/GitVersionCore.Tests/GitFlow/MetaDataByCommitFixture.cs b/GitVersionCore.Tests/GitFlow/MetaDataByCommitScenarios.cs similarity index 99% rename from GitVersionCore.Tests/GitFlow/MetaDataByCommitFixture.cs rename to GitVersionCore.Tests/GitFlow/MetaDataByCommitScenarios.cs index 957a9ab8d9..b52ed2214f 100644 --- a/GitVersionCore.Tests/GitFlow/MetaDataByCommitFixture.cs +++ b/GitVersionCore.Tests/GitFlow/MetaDataByCommitScenarios.cs @@ -3,7 +3,7 @@ using Shouldly; [TestFixture] -public class MetaDataByCommitFixture +public class MetaDataByCommitScenarios { /* * hotfix-1.2.1 -----------C-- diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj index bd59df0ce9..8bf75acec2 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -65,13 +65,14 @@ Helpers\DirectoryHelper.cs - + - + - + + @@ -81,12 +82,12 @@ - + - + From bb39373cd29550f9a246ccfc09079434691077fa Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 22:50:44 +0000 Subject: [PATCH 09/17] Moved integration tests into a sub folder --- .../GitVersionCore.Tests.csproj | 17 +++++++++-------- .../GitFlow/DevelopScenarios.cs | 0 .../GitFlow/MetaDataByCommitScenarios.cs | 0 .../GitFlow/PatchScenarios.cs | 0 .../GitFlow/ReleaseBranchTests.cs | 0 .../GitFlow/WikiScenarios.cs | 0 .../GitHubFlow/MasterTests.cs | 0 .../GitHubFlow/OtherBranchTests.cs | 0 .../GitHubFlow/ReleaseBranchTests.cs | 0 9 files changed, 9 insertions(+), 8 deletions(-) rename GitVersionCore.Tests/{ => IntegrationTests}/GitFlow/DevelopScenarios.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitFlow/MetaDataByCommitScenarios.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitFlow/PatchScenarios.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitFlow/ReleaseBranchTests.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitFlow/WikiScenarios.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitHubFlow/MasterTests.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitHubFlow/OtherBranchTests.cs (100%) rename GitVersionCore.Tests/{ => IntegrationTests}/GitHubFlow/ReleaseBranchTests.cs (100%) diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 8bf75acec2..65f3b2e036 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -69,13 +69,13 @@ - - - - - - - + + + + + + + @@ -85,7 +85,7 @@ - + @@ -173,6 +173,7 @@ + diff --git a/GitVersionCore.Tests/GitFlow/DevelopScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/DevelopScenarios.cs rename to GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs diff --git a/GitVersionCore.Tests/GitFlow/MetaDataByCommitScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/MetaDataByCommitScenarios.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/MetaDataByCommitScenarios.cs rename to GitVersionCore.Tests/IntegrationTests/GitFlow/MetaDataByCommitScenarios.cs diff --git a/GitVersionCore.Tests/GitFlow/PatchScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/PatchScenarios.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/PatchScenarios.cs rename to GitVersionCore.Tests/IntegrationTests/GitFlow/PatchScenarios.cs diff --git a/GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/ReleaseBranchTests.cs rename to GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs diff --git a/GitVersionCore.Tests/GitFlow/WikiScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs similarity index 100% rename from GitVersionCore.Tests/GitFlow/WikiScenarios.cs rename to GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs diff --git a/GitVersionCore.Tests/GitHubFlow/MasterTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs similarity index 100% rename from GitVersionCore.Tests/GitHubFlow/MasterTests.cs rename to GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs diff --git a/GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs similarity index 100% rename from GitVersionCore.Tests/GitHubFlow/OtherBranchTests.cs rename to GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs diff --git a/GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs similarity index 100% rename from GitVersionCore.Tests/GitHubFlow/ReleaseBranchTests.cs rename to GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs From 31d42088106e6ca9100260c74e18b8bfb0022f65 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 23:08:09 +0000 Subject: [PATCH 10/17] Added tag-prefix configuration option --- .../GitHubFlow/MasterTests.cs | 26 +++++++++++++++++++ GitVersionCore/Configuration/Config.cs | 4 +++ .../GitHubFlow/LastTaggedReleaseFinder.cs | 4 ++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs index 61858ca7df..e621bc3ca4 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs @@ -136,4 +136,30 @@ public void GivenARepositoryWithTagAndOldNextVersionTxtFileAndNoCommits_VersionS fixture.AssertFullSemver("1.1.0+0"); } } + + [Test] + public void CanSpecifyTagPrefixes() + { + using (var fixture = new EmptyRepositoryFixture(new Config{ TagPrefix = "version-"})) + { + const string TaggedVersion = "version-1.0.3"; + fixture.Repository.MakeATaggedCommit(TaggedVersion); + fixture.Repository.MakeCommits(5); + + fixture.AssertFullSemver("1.0.4+5"); + } + } + + [Test] + public void CanSpecifyTagPrefixesAsRegex() + { + using (var fixture = new EmptyRepositoryFixture(new Config{ TagPrefix = "[version-|v]"})) + { + const string TaggedVersion = "v1.0.3"; + fixture.Repository.MakeATaggedCommit(TaggedVersion); + fixture.Repository.MakeCommits(5); + + fixture.AssertFullSemver("1.0.4+5"); + } + } } \ No newline at end of file diff --git a/GitVersionCore/Configuration/Config.cs b/GitVersionCore/Configuration/Config.cs index 6dd9eb5073..0a13d06e5d 100644 --- a/GitVersionCore/Configuration/Config.cs +++ b/GitVersionCore/Configuration/Config.cs @@ -9,6 +9,7 @@ public Config() AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch; DevelopBranchTag = "unstable"; ReleaseBranchTag = "beta"; + TagPrefix = "v"; } public AssemblyVersioningScheme AssemblyVersioningScheme { get; set; } @@ -18,5 +19,8 @@ public Config() [YamlAlias("release-branch-tag")] public string ReleaseBranchTag { get; set; } + + [YamlAlias("tag-prefix")] + public string TagPrefix { get; set; } } } \ No newline at end of file diff --git a/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs b/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs index 9c6acccb53..0d6f7a632d 100644 --- a/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs +++ b/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs @@ -1,6 +1,7 @@ namespace GitVersion { using System.Linq; + using System.Text.RegularExpressions; using LibGit2Sharp; public class LastTaggedReleaseFinder @@ -16,8 +17,9 @@ public bool GetVersion(out VersionTaggedCommit versionTaggedCommit) { var tags = context.Repository.Tags.Select(t => { + var match = Regex.Match(t.Name, string.Format("({0})?(?.*)", context.Configuration.TagPrefix)); SemanticVersion version; - if (SemanticVersion.TryParse(t.Name.TrimStart('v'), out version)) + if (SemanticVersion.TryParse(match.Groups["version"].Value, out version)) { return new VersionTaggedCommit((Commit)t.Target, version); } From a0037a6263f479fed36c95c76dbf7c1b844a2b1a Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 23:17:30 +0000 Subject: [PATCH 11/17] Added Tag prefix support to Task --- GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 7 +++++++ GitVersionTask/GetVersion.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 5a4b162d66..a17b93e133 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -16,6 +16,8 @@ public class UpdateAssemblyInfo : Task public string ReleaseBranchTag { get; set; } + public string TagPrefix { get; set; } + [Required] public string SolutionDirectory { get; set; } @@ -97,6 +99,11 @@ public void InnerExecute() config.ReleaseBranchTag = ReleaseBranchTag; } + if (TagPrefix != null) + { + config.TagPrefix = TagPrefix; + } + CachedVersion semanticVersion; if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) { diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index e08a43bc31..aa936ab158 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -76,6 +76,8 @@ public class GetVersion : Task public string ReleaseBranchTag { get; set; } + public string TagPrefix { get; set; } + TaskLogger logger; public GetVersion() @@ -105,6 +107,11 @@ public override bool Execute() config.ReleaseBranchTag = ReleaseBranchTag; } + if (TagPrefix != null) + { + config.TagPrefix = TagPrefix; + } + if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, config)) { var thisType = typeof(GetVersion); From e48ed596dc4b3aae8bec37780cc3954989939537 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 23:24:52 +0000 Subject: [PATCH 12/17] Remove the [vV] stripping from the front of the Regex on the SemanticVersion class. This is done elsewhere --- GitVersionCore/SemanticVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersionCore/SemanticVersion.cs b/GitVersionCore/SemanticVersion.cs index 49dcaa9159..a90a324f4c 100644 --- a/GitVersionCore/SemanticVersion.cs +++ b/GitVersionCore/SemanticVersion.cs @@ -6,7 +6,7 @@ namespace GitVersion public class SemanticVersion : IFormattable, IComparable { static Regex ParseSemVer = new Regex( - @"[vV]?(?(?\d+)(\.(?\d+))?(\.(?\d+))?)(\.(?\d+))?(-(?[^\+]*))?(\+(?.*))?", + @"(?(?\d+)(\.(?\d+))?(\.(?\d+))?)(\.(?\d+))?(-(?[^\+]*))?(\+(?.*))?", RegexOptions.Compiled); public int Major; From a28c18a0e8409017cbf6a51a6921ee6e7f0df42b Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sat, 15 Nov 2014 23:57:35 +0000 Subject: [PATCH 13/17] Fixed #242 --- .../JsonVersionBuilderTests.Json.approved.txt | 1 + .../JsonVersionBuilderTests.cs | 3 +- GitVersionCore.Tests/VariableProviderTests.cs | 3 +- GitVersionCore/AssemblyVersioningScheme.cs | 1 + GitVersionCore/AssemblyVersionsGenerator.cs | 45 +++++++++++++++++ GitVersionCore/GitVersionCore.csproj | 1 + .../OutputFormatters/BuildOutputFormatter.cs | 3 +- .../OutputVariables/VariableProvider.cs | 8 +-- GitVersionExe/AssemblyInfoFileUpdate.cs | 2 +- GitVersionExe/Program.cs | 5 +- ...s.VerifyAssemblyVersion_Major.approved.txt | 3 +- ...ifyAssemblyVersion_MajorMinor.approved.txt | 3 +- ...semblyVersion_MajorMinorPatch.approved.txt | 1 + ...rsion_MajorMinorPatchMetadata.approved.txt | 50 +++++++++++++++++++ ...uilderTests.VerifyCreatedCode.approved.txt | 1 + .../AssemblyInfoBuilderTests.cs | 13 +++-- GitVersionTask.Tests/GetVersionTaskTests.cs | 3 +- .../AssemblyInfoBuilder.cs | 10 ++-- .../AssemblyVersionsGenerator.cs | 24 --------- .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 5 +- GitVersionTask/GetVersion.cs | 5 +- GitVersionTask/GitVersionTask.csproj | 1 - 22 files changed, 143 insertions(+), 48 deletions(-) create mode 100644 GitVersionCore/AssemblyVersionsGenerator.cs create mode 100644 GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt delete mode 100644 GitVersionTask/AssemblyInfoBuilder/AssemblyVersionsGenerator.cs diff --git a/GitVersionCore.Tests/JsonVersionBuilderTests.Json.approved.txt b/GitVersionCore.Tests/JsonVersionBuilderTests.Json.approved.txt index 58e95e63e8..d8f088b481 100644 --- a/GitVersionCore.Tests/JsonVersionBuilderTests.Json.approved.txt +++ b/GitVersionCore.Tests/JsonVersionBuilderTests.Json.approved.txt @@ -11,6 +11,7 @@ "LegacySemVer":"1.2.3-unstable4", "LegacySemVerPadded":"1.2.3-unstable0004", "AssemblySemVer":"1.2.3.0", + "AssemblyFileSemVer":"1.2.3.0", "FullSemVer":"1.2.3-unstable.4+5", "InformationalVersion":"1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha", "ClassicVersion":"1.2.3.5", diff --git a/GitVersionCore.Tests/JsonVersionBuilderTests.cs b/GitVersionCore.Tests/JsonVersionBuilderTests.cs index 42101b0f3b..4051c69431 100644 --- a/GitVersionCore.Tests/JsonVersionBuilderTests.cs +++ b/GitVersionCore.Tests/JsonVersionBuilderTests.cs @@ -1,6 +1,7 @@ using System; using ApprovalTests; using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; [TestFixture] @@ -17,7 +18,7 @@ public void Json() PreReleaseTag = "unstable4", BuildMetaData = new SemanticVersionBuildMetaData(5, "feature1", "commitSha",DateTimeOffset.Parse("2014-03-06 23:59:59Z")) }; - var variables = VariableProvider.GetVariablesFor(semanticVersion); + var variables = VariableProvider.GetVariablesFor(semanticVersion, new Config()); var json = JsonOutputFormatter.ToJson(variables); Approvals.Verify(json); } diff --git a/GitVersionCore.Tests/VariableProviderTests.cs b/GitVersionCore.Tests/VariableProviderTests.cs index efc969edbc..7d73b64211 100644 --- a/GitVersionCore.Tests/VariableProviderTests.cs +++ b/GitVersionCore.Tests/VariableProviderTests.cs @@ -1,5 +1,6 @@ using System; using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; using Shouldly; @@ -22,7 +23,7 @@ public void DevelopBranchFormatsSemVerForCiFeed() semVer.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z"); - var vars = VariableProvider.GetVariablesFor(semVer); + var vars = VariableProvider.GetVariablesFor(semVer, new Config()); vars[VariableProvider.SemVer].ShouldBe("1.2.3.5-unstable"); } diff --git a/GitVersionCore/AssemblyVersioningScheme.cs b/GitVersionCore/AssemblyVersioningScheme.cs index f2f061046b..603c446b78 100644 --- a/GitVersionCore/AssemblyVersioningScheme.cs +++ b/GitVersionCore/AssemblyVersioningScheme.cs @@ -2,6 +2,7 @@ { public enum AssemblyVersioningScheme { + MajorMinorPatchMetadata, MajorMinorPatch, MajorMinor, Major, diff --git a/GitVersionCore/AssemblyVersionsGenerator.cs b/GitVersionCore/AssemblyVersionsGenerator.cs new file mode 100644 index 0000000000..a8e218a64a --- /dev/null +++ b/GitVersionCore/AssemblyVersionsGenerator.cs @@ -0,0 +1,45 @@ +namespace GitVersion +{ + using System; + + public static class AssemblyVersionsGenerator + { + public static string GetAssemblyVersion( + this SemanticVersion sv, + AssemblyVersioningScheme scheme) + { + switch (scheme) + { + case AssemblyVersioningScheme.Major: + return string.Format("{0}.0.0.0", sv.Major); + case AssemblyVersioningScheme.MajorMinor: + return string.Format("{0}.{1}.0.0", sv.Major, sv.Minor); + case AssemblyVersioningScheme.MajorMinorPatch: + return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch); + case AssemblyVersioningScheme.MajorMinorPatchMetadata: + return string.Format("{0}.{1}.{2}.{3}", sv.Major, sv.Minor, sv.Patch, sv.BuildMetaData.CommitsSinceTag ?? 0); + default: + throw new ArgumentException(string.Format("Unexpected value ({0}).", scheme), "scheme"); + } + + } + public static string GetAssemblyFileVersion( + this SemanticVersion sv, + AssemblyVersioningScheme scheme) + { + switch (scheme) + { + case AssemblyVersioningScheme.Major: + case AssemblyVersioningScheme.MajorMinor: + case AssemblyVersioningScheme.MajorMinorPatch: + return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch); + case AssemblyVersioningScheme.MajorMinorPatchMetadata: + return string.Format("{0}.{1}.{2}.{3}", sv.Major, sv.Minor, sv.Patch, sv.BuildMetaData.CommitsSinceTag ?? 0); + default: + throw new ArgumentException(string.Format("Unexpected value ({0}).", scheme), "scheme"); + } + + } + + } +} \ No newline at end of file diff --git a/GitVersionCore/GitVersionCore.csproj b/GitVersionCore/GitVersionCore.csproj index 7674295956..1e10be6071 100644 --- a/GitVersionCore/GitVersionCore.csproj +++ b/GitVersionCore/GitVersionCore.csproj @@ -59,6 +59,7 @@ + diff --git a/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs b/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs index 1cbf7abb6b..1c910cadcf 100644 --- a/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs +++ b/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs @@ -1,6 +1,7 @@ namespace GitVersion { using System.Collections.Generic; + using GitVersion.Configuration; public static class BuildOutputFormatter { @@ -8,7 +9,7 @@ public static IEnumerable GenerateBuildLogOutput(SemanticVersion semanti { var output = new List(); - foreach (var variable in VariableProvider.GetVariablesFor(semanticVersion)) + foreach (var variable in VariableProvider.GetVariablesFor(semanticVersion, new Config())) { output.AddRange(buildServer.GenerateSetParameterMessage(variable.Key, variable.Value)); } diff --git a/GitVersionCore/OutputVariables/VariableProvider.cs b/GitVersionCore/OutputVariables/VariableProvider.cs index 2cdf76f49d..e46fb1fb63 100644 --- a/GitVersionCore/OutputVariables/VariableProvider.cs +++ b/GitVersionCore/OutputVariables/VariableProvider.cs @@ -2,6 +2,7 @@ { using System; using System.Collections.Generic; + using GitVersion.Configuration; public static class VariableProvider { @@ -18,6 +19,7 @@ public static class VariableProvider public const string LegacySemVerPadded = "LegacySemVerPadded"; public const string FullSemVer = "FullSemVer"; public const string AssemblySemVer = "AssemblySemVer"; + public const string AssemblyFileSemVer = "AssemblyFileSemVer"; public const string ClassicVersion = "ClassicVersion"; public const string ClassicVersionWithTag = "ClassicVersionWithTag"; public const string PreReleaseTag = "PreReleaseTag"; @@ -30,8 +32,7 @@ public static class VariableProvider public const string NuGetVersionV3 = "NuGetVersionV3"; public const string NuGetVersion = "NuGetVersion"; - public static Dictionary GetVariablesFor( - SemanticVersion semanticVersion) + public static Dictionary GetVariablesFor(SemanticVersion semanticVersion, Config configuration) { var bmd = semanticVersion.BuildMetaData; var formatter = bmd.Branch == "develop" ? new CiFeedFormatter() : null; @@ -49,7 +50,8 @@ public static Dictionary GetVariablesFor( {SemVer, semanticVersion.ToString(null, formatter)}, {LegacySemVer, semanticVersion.ToString("l", formatter)}, {LegacySemVerPadded, semanticVersion.ToString("lp", formatter)}, - {AssemblySemVer, semanticVersion.ToString("j") + ".0"}, + {AssemblySemVer, semanticVersion.GetAssemblyVersion(configuration.AssemblyVersioningScheme)}, + {AssemblyFileSemVer, semanticVersion.GetAssemblyFileVersion(configuration.AssemblyVersioningScheme)}, {FullSemVer, semanticVersion.ToString("f", formatter)}, {InformationalVersion, semanticVersion.ToString("i", formatter)}, {ClassicVersion, string.Format("{0}.{1}", semanticVersion.ToString("j"), (bmd.CommitsSinceTag ?? 0))}, diff --git a/GitVersionExe/AssemblyInfoFileUpdate.cs b/GitVersionExe/AssemblyInfoFileUpdate.cs index 36a7f2f130..1110d67c99 100644 --- a/GitVersionExe/AssemblyInfoFileUpdate.cs +++ b/GitVersionExe/AssemblyInfoFileUpdate.cs @@ -33,7 +33,7 @@ public AssemblyInfoFileUpdate(Arguments args, string workingDirectory, Dictionar var assemblyVersion = string.Format("{0}.{1}.0.0", variables[VariableProvider.Major], variables[VariableProvider.Minor]); var assemblyInfoVersion = variables[VariableProvider.InformationalVersion]; - var assemblyFileVersion = variables[VariableProvider.MajorMinorPatch]; + var assemblyFileVersion = variables[VariableProvider.AssemblySemVer]; var fileContents = File.ReadAllText(assemblyInfoFile) .RegexReplace(@"AssemblyVersion\(""\d+.\d+.\d+(.\d+|\*)?""\)", string.Format("AssemblyVersion(\"{0}\")", assemblyVersion)) .RegexReplace(@"AssemblyInformationalVersion\(""\d+.\d+.\d+(.\d+|\*)?""\)", string.Format("AssemblyInformationalVersion(\"{0}\")", assemblyInfoVersion)) diff --git a/GitVersionExe/Program.cs b/GitVersionExe/Program.cs index 925537841f..6936f5e8e6 100644 --- a/GitVersionExe/Program.cs +++ b/GitVersionExe/Program.cs @@ -80,9 +80,10 @@ static int Run() } SemanticVersion semanticVersion; var versionFinder = new GitVersionFinder(); + var configuration = ConfigurationProvider.Provide(gitDirectory); using (var repo = RepositoryLoader.GetRepo(gitDirectory)) { - var gitVersionContext = new GitVersionContext(repo, ConfigurationProvider.Provide(gitDirectory)); + var gitVersionContext = new GitVersionContext(repo, configuration); semanticVersion = versionFinder.FindVersion(gitVersionContext); } @@ -94,7 +95,7 @@ static int Run() } } - var variables = VariableProvider.GetVariablesFor(semanticVersion); + var variables = VariableProvider.GetVariablesFor(semanticVersion, configuration); if (arguments.Output == OutputType.Json) { switch (arguments.VersionPart) diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt index 240b386c5c..f7cc35d65f 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_Major.approved.txt @@ -34,7 +34,8 @@ static class GitVersionInformation public static string SemVer = "2.3.4"; public static string LegacySemVer = "2.3.4"; public static string LegacySemVerPadded = "2.3.4"; - public static string AssemblySemVer = "2.3.4.0"; + public static string AssemblySemVer = "2.0.0.0"; + public static string AssemblyFileSemVer = "2.3.4.0"; public static string FullSemVer = "2.3.4+5"; public static string InformationalVersion = "2.3.4+5.Branch.master.Sha.commitSha"; public static string ClassicVersion = "2.3.4.5"; diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt index d2be3bebb2..a9c7d94bd1 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinor.approved.txt @@ -34,7 +34,8 @@ static class GitVersionInformation public static string SemVer = "2.3.4"; public static string LegacySemVer = "2.3.4"; public static string LegacySemVerPadded = "2.3.4"; - public static string AssemblySemVer = "2.3.4.0"; + public static string AssemblySemVer = "2.3.0.0"; + public static string AssemblyFileSemVer = "2.3.4.0"; public static string FullSemVer = "2.3.4+5"; public static string InformationalVersion = "2.3.4+5.Branch.master.Sha.commitSha"; public static string ClassicVersion = "2.3.4.5"; diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt index 2992714dad..412c16d245 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatch.approved.txt @@ -35,6 +35,7 @@ static class GitVersionInformation public static string LegacySemVer = "2.3.4"; public static string LegacySemVerPadded = "2.3.4"; public static string AssemblySemVer = "2.3.4.0"; + public static string AssemblyFileSemVer = "2.3.4.0"; public static string FullSemVer = "2.3.4+5"; public static string InformationalVersion = "2.3.4+5.Branch.master.Sha.commitSha"; public static string ClassicVersion = "2.3.4.5"; diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt new file mode 100644 index 0000000000..9a283d45c7 --- /dev/null +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyAssemblyVersion_MajorMinorPatchMetadata.approved.txt @@ -0,0 +1,50 @@ + +using System; +using System.Reflection; + +[assembly: AssemblyVersion("2.3.4.5")] +[assembly: AssemblyFileVersion("2.3.4.5")] +[assembly: AssemblyInformationalVersion("2.3.4+5.Branch.master.Sha.commitSha")] +[assembly: ReleaseDate("2014-03-01", "2014-03-06")] + +[System.Runtime.CompilerServices.CompilerGenerated] +sealed class ReleaseDateAttribute : System.Attribute +{ + public string OriginalDate { get; private set; } + public string Date { get; private set; } + + public ReleaseDateAttribute(string originalDate, string date) + { + OriginalDate = date; + Date = date; + } +} + +[System.Runtime.CompilerServices.CompilerGenerated] +static class GitVersionInformation +{ + public static string Major = "2"; + public static string Minor = "3"; + public static string Patch = "4"; + public static string PreReleaseTag = ""; + public static string PreReleaseTagWithDash = ""; + public static string BuildMetaData = "5"; + public static string FullBuildMetaData = "5.Branch.master.Sha.commitSha"; + public static string MajorMinorPatch = "2.3.4"; + public static string SemVer = "2.3.4"; + public static string LegacySemVer = "2.3.4"; + public static string LegacySemVerPadded = "2.3.4"; + public static string AssemblySemVer = "2.3.4.5"; + public static string AssemblyFileSemVer = "2.3.4.5"; + public static string FullSemVer = "2.3.4+5"; + public static string InformationalVersion = "2.3.4+5.Branch.master.Sha.commitSha"; + public static string ClassicVersion = "2.3.4.5"; + public static string ClassicVersionWithTag = "2.3.4.5"; + public static string BranchName = "master"; + public static string Sha = "commitSha"; + public static string NuGetVersionV2 = "2.3.4"; + public static string NuGetVersion = "2.3.4"; + +} + + diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt index f3e042aeac..c0c975a09e 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.VerifyCreatedCode.approved.txt @@ -35,6 +35,7 @@ static class GitVersionInformation public static string LegacySemVer = "1.2.3-unstable4"; public static string LegacySemVerPadded = "1.2.3-unstable0004"; public static string AssemblySemVer = "1.2.3.0"; + public static string AssemblyFileSemVer = "1.2.3.0"; public static string FullSemVer = "1.2.3-unstable.4+5"; public static string InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"; public static string ClassicVersion = "1.2.3.5"; diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs b/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs index 360becb559..bb778ad15b 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs @@ -4,6 +4,7 @@ using System.Runtime.CompilerServices; using ApprovalTests; using GitVersion; +using GitVersion.Configuration; using NUnit.Framework; using Roslyn.Compilers; using Roslyn.Compilers.CSharp; @@ -32,7 +33,7 @@ public void VerifyCreatedCode() MasterReleaseDate = DateTimeOffset.Parse("2014-03-01 00:00:01Z"), } }; - var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(); + var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(new Config()); Approvals.Verify(assemblyInfoText); var syntaxTree = SyntaxTree.ParseText(assemblyInfoText); var references = new[] {new MetadataFileReference(typeof(object).Assembly.Location)}; @@ -62,6 +63,13 @@ public void VerifyAssemblyVersion_MajorMinorPatch() VerifyAssemblyVersion(AssemblyVersioningScheme.MajorMinorPatch); } + [Test] + [MethodImpl(MethodImplOptions.NoInlining)] + public void VerifyAssemblyVersion_MajorMinorPatchMetadata() + { + VerifyAssemblyVersion(AssemblyVersioningScheme.MajorMinorPatchMetadata); + } + static void VerifyAssemblyVersion(AssemblyVersioningScheme avs) { var semanticVersion = new SemanticVersion @@ -79,10 +87,9 @@ static void VerifyAssemblyVersion(AssemblyVersioningScheme avs) SemanticVersion = semanticVersion, MasterReleaseDate = DateTimeOffset.Parse("2014-03-01 00:00:01Z") }, - AssemblyVersioningScheme = avs, }; - var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(); + var assemblyInfoText = assemblyInfoBuilder.GetAssemblyInfoText(new Config { AssemblyVersioningScheme = avs }); Approvals.Verify(assemblyInfoText); var syntaxTree = SyntaxTree.ParseText(assemblyInfoText); var references = new[] { new MetadataFileReference(typeof(object).Assembly.Location)}; diff --git a/GitVersionTask.Tests/GetVersionTaskTests.cs b/GitVersionTask.Tests/GetVersionTaskTests.cs index 0153052fb9..6e11dc36be 100644 --- a/GitVersionTask.Tests/GetVersionTaskTests.cs +++ b/GitVersionTask.Tests/GetVersionTaskTests.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using GitVersion; +using GitVersion.Configuration; using GitVersionTask; using Microsoft.Build.Framework; using NUnit.Framework; @@ -21,7 +22,7 @@ public void OutputsShouldMatchVariableProvider() Minor = 2, Patch = 3, BuildMetaData = new SemanticVersionBuildMetaData(5, "develop", "commitSha",DateTimeOffset.Parse("2014-03-06 23:59:59Z")) - }).Keys; + }, new Config()).Keys; CollectionAssert.AreEquivalent(properties, variables); } diff --git a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs index 5f023f3f1f..77ebaaa209 100644 --- a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs +++ b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs @@ -1,16 +1,16 @@ using System.Collections.Generic; using System.Text; using GitVersion; +using GitVersion.Configuration; public class AssemblyInfoBuilder { public CachedVersion CachedVersion; - public AssemblyVersioningScheme AssemblyVersioningScheme; - public string GetAssemblyInfoText() + public string GetAssemblyInfoText(Config configuration) { var semanticVersion = CachedVersion.SemanticVersion; - var vars = VariableProvider.GetVariablesFor(semanticVersion); + var vars = VariableProvider.GetVariablesFor(semanticVersion, configuration); var assemblyInfo = string.Format(@" using System; using System.Reflection; @@ -40,7 +40,9 @@ static class GitVersionInformation }} -", semanticVersion.GetAssemblyVersion(AssemblyVersioningScheme), string.Format("{0}.{1}.{2}.0", semanticVersion.Major, semanticVersion.Minor, semanticVersion.Patch), semanticVersion.ToString("i"), +", vars[VariableProvider.AssemblySemVer], + vars[VariableProvider.AssemblyFileSemVer], + semanticVersion.ToString("i"), CachedVersion.MasterReleaseDate.UtcDateTime.ToString("yyyy-MM-dd"), semanticVersion.BuildMetaData.CommitDate.UtcDateTime.ToString("yyyy-MM-dd"), GenerateVariableMembers(vars)); diff --git a/GitVersionTask/AssemblyInfoBuilder/AssemblyVersionsGenerator.cs b/GitVersionTask/AssemblyInfoBuilder/AssemblyVersionsGenerator.cs deleted file mode 100644 index b7263d290e..0000000000 --- a/GitVersionTask/AssemblyInfoBuilder/AssemblyVersionsGenerator.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using GitVersion; - -public static class AssemblyVersionsGenerator -{ - public static string GetAssemblyVersion( - this SemanticVersion sv, - AssemblyVersioningScheme scheme) - { - switch (scheme) - { - case AssemblyVersioningScheme.Major: - return string.Format("{0}.0.0.0", sv.Major); - case AssemblyVersioningScheme.MajorMinor: - return string.Format("{0}.{1}.0.0", sv.Major, sv.Minor); - case AssemblyVersioningScheme.MajorMinorPatch: - return string.Format("{0}.{1}.{2}.0", sv.Major, sv.Minor, sv.Patch); - default: - throw new ArgumentException(string.Format("Unexpected value ({0}).", scheme), "scheme"); - } - - } - -} \ No newline at end of file diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index a17b93e133..3a13902a8c 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -133,10 +133,9 @@ void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config config) { var assemblyInfoBuilder = new AssemblyInfoBuilder { - CachedVersion = semanticVersion, - AssemblyVersioningScheme = config.AssemblyVersioningScheme, + CachedVersion = semanticVersion }; - var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(); + var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(config); var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName()); AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName); diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index aa936ab158..a1f305aeeb 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -48,6 +48,9 @@ public class GetVersion : Task [Output] public string AssemblySemVer { get; set; } + [Output] + public string AssemblyFileSemVer { get; set; } + [Output] public string FullSemVer { get; set; } @@ -115,7 +118,7 @@ public override bool Execute() if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, config)) { var thisType = typeof(GetVersion); - var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion); + var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion, config); foreach (var variable in variables) { thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null); diff --git a/GitVersionTask/GitVersionTask.csproj b/GitVersionTask/GitVersionTask.csproj index d947eee737..92eb116a8d 100644 --- a/GitVersionTask/GitVersionTask.csproj +++ b/GitVersionTask/GitVersionTask.csproj @@ -55,7 +55,6 @@ - From 206ebe290981619f6d6b11aedf5c151c52abd813 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sun, 16 Nov 2014 15:29:43 +0000 Subject: [PATCH 14/17] Fixed variable naming --- .../Fixtures/EmptyRepositoryFixture.cs | 4 +-- .../Fixtures/RepositoryFixtureBase.cs | 2 +- .../GitHubFlow/ReleaseBranchTests.cs | 2 +- .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 35 +++++-------------- GitVersionTask/GetVersion.cs | 12 +++---- GitVersionTask/WriteVersionInfoToBuildLog.cs | 4 +-- 6 files changed, 21 insertions(+), 38 deletions(-) diff --git a/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs b/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs index 57751e8e5c..cac9cb2c4e 100644 --- a/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs +++ b/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs @@ -4,8 +4,8 @@ public class EmptyRepositoryFixture : RepositoryFixtureBase { - public EmptyRepositoryFixture(Config config) : - base(CreateNewRepository, config) + public EmptyRepositoryFixture(Config configuration) : + base(CreateNewRepository, configuration) { } diff --git a/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs b/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs index 62c37167d2..20cf020f1d 100644 --- a/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs +++ b/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs @@ -8,7 +8,7 @@ public abstract class RepositoryFixtureBase : IDisposable { public string RepositoryPath; public IRepository Repository; - Config configuration; + private Config configuration; protected RepositoryFixtureBase(Func repoBuilder, Config configuration) { diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs index 262ffafe40..4418205a43 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs @@ -76,7 +76,7 @@ public void WhenReleaseBranchIsMergedIntoMasterHighestVersionIsTakenWithIt() [Test] public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion() { - using (var fixture = new EmptyRepositoryFixture()) + using (var fixture = new EmptyRepositoryFixture(new Config())) { const string TaggedVersion = "1.0.3"; fixture.Repository.MakeATaggedCommit(TaggedVersion); diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 3a13902a8c..90efc23a27 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -73,13 +73,13 @@ public void InnerExecute() if (string.IsNullOrEmpty(gitDirectory)) return; - var config = ConfigurationProvider.Provide(gitDirectory); + var configuration = ConfigurationProvider.Provide(gitDirectory); if (!string.IsNullOrEmpty(AssemblyVersioningScheme)) { AssemblyVersioningScheme versioningScheme; if (Enum.TryParse(AssemblyVersioningScheme, true, out versioningScheme)) { - config.AssemblyVersioningScheme = versioningScheme; + configuration.AssemblyVersioningScheme = versioningScheme; } else { @@ -91,51 +91,34 @@ public void InnerExecute() // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag if (DevelopBranchTag != null) { - config.DevelopBranchTag = DevelopBranchTag; + configuration.DevelopBranchTag = DevelopBranchTag; } if (ReleaseBranchTag != null) { - config.ReleaseBranchTag = ReleaseBranchTag; + configuration.ReleaseBranchTag = ReleaseBranchTag; } if (TagPrefix != null) { - config.TagPrefix = TagPrefix; + configuration.TagPrefix = TagPrefix; } CachedVersion semanticVersion; - if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) + if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, configuration)) { return; } - CreateTempAssemblyInfo(semanticVersion, config); + CreateTempAssemblyInfo(semanticVersion, configuration); } - AssemblyVersioningScheme GetAssemblyVersioningScheme(Config config) - { - if (string.IsNullOrWhiteSpace(AssemblyVersioningScheme)) - { - return config.AssemblyVersioningScheme; - } - - AssemblyVersioningScheme versioningScheme; - - if (Enum.TryParse(AssemblyVersioningScheme, true, out versioningScheme)) - { - return versioningScheme; - } - - throw new WarningException(string.Format("Unexpected assembly versioning scheme '{0}'.", AssemblyVersioningScheme)); - } - - void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config config) + void CreateTempAssemblyInfo(CachedVersion semanticVersion, Config configuration) { var assemblyInfoBuilder = new AssemblyInfoBuilder { CachedVersion = semanticVersion }; - var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(config); + var assemblyInfo = assemblyInfoBuilder.GetAssemblyInfoText(configuration); var tempFileName = string.Format("AssemblyInfo_{0}_{1}.g.cs", Path.GetFileNameWithoutExtension(ProjectFile), Path.GetRandomFileName()); AssemblyInfoTempFilePath = Path.Combine(TempFileTracker.TempPath, tempFileName); diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index a1f305aeeb..8b127ac5e9 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -96,29 +96,29 @@ public override bool Execute() { CachedVersion versionAndBranch; var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); - var config = ConfigurationProvider.Provide(gitDirectory); + var configuration = ConfigurationProvider.Provide(gitDirectory); // TODO This should be covered by tests // Null is intentional. Empty string means the user has set the value to an empty string and wants to clear the tag if (DevelopBranchTag != null) { - config.DevelopBranchTag = DevelopBranchTag; + configuration.DevelopBranchTag = DevelopBranchTag; } if (ReleaseBranchTag != null) { - config.ReleaseBranchTag = ReleaseBranchTag; + configuration.ReleaseBranchTag = ReleaseBranchTag; } if (TagPrefix != null) { - config.TagPrefix = TagPrefix; + configuration.TagPrefix = TagPrefix; } - if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, config)) + if (VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out versionAndBranch, configuration)) { var thisType = typeof(GetVersion); - var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion, config); + var variables = VariableProvider.GetVariablesFor(versionAndBranch.SemanticVersion, configuration); foreach (var variable in variables) { thisType.GetProperty(variable.Key).SetValue(this, variable.Value, null); diff --git a/GitVersionTask/WriteVersionInfoToBuildLog.cs b/GitVersionTask/WriteVersionInfoToBuildLog.cs index 7d4a57c4cc..6354a6d470 100644 --- a/GitVersionTask/WriteVersionInfoToBuildLog.cs +++ b/GitVersionTask/WriteVersionInfoToBuildLog.cs @@ -49,8 +49,8 @@ public void InnerExecute() { CachedVersion semanticVersion; var gitDirectory = GitDirFinder.TreeWalkForGitDir(SolutionDirectory); - var config = ConfigurationProvider.Provide(gitDirectory); - if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, config)) + var configuration = ConfigurationProvider.Provide(gitDirectory); + if (!VersionAndBranchFinder.TryGetVersion(SolutionDirectory, out semanticVersion, configuration)) { return; } From 81779f792fc3dc725718b37e9291b7ccd03421aa Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sun, 16 Nov 2014 15:42:40 +0000 Subject: [PATCH 15/17] Updated other places which required git tag prefix cleanup --- GitVersionCore.Tests/SemanticVersionTests.cs | 44 +++++++++---------- .../DevelopBasedVersionFinderBase.cs | 2 +- .../BranchFinders/DevelopVersionFinder.cs | 2 +- .../RecentTagVersionExtractor.cs | 4 +- .../BranchFinders/ReleaseVersionFinder.cs | 4 +- .../BranchFinders/SupportVersionFinder.cs | 5 ++- .../GitFlow/GitFlowVersionFinder.cs | 2 +- .../GitHubFlow/GitHubFlowVersionFinder.cs | 2 +- .../GitHubFlow/LastTaggedReleaseFinder.cs | 4 +- .../GitHubFlow/NextVersionTxtFileFinder.cs | 7 ++- .../GitHubFlow/OtherBranchVersionFinder.cs | 2 +- GitVersionCore/LibGitExtensions.cs | 5 ++- GitVersionCore/SemanticVersion.cs | 8 ++-- GitVersionCore/SemanticVersionExtensions.cs | 5 ++- 14 files changed, 51 insertions(+), 45 deletions(-) diff --git a/GitVersionCore.Tests/SemanticVersionTests.cs b/GitVersionCore.Tests/SemanticVersionTests.cs index ece45ea650..445f2ad2b8 100644 --- a/GitVersionCore.Tests/SemanticVersionTests.cs +++ b/GitVersionCore.Tests/SemanticVersionTests.cs @@ -31,7 +31,7 @@ public void ValidateVersionParsing(string versionString, int major, int minor, i fullFormattedVersionString = fullFormattedVersionString ?? versionString; SemanticVersion version; - Assert.IsTrue(SemanticVersion.TryParse(versionString, out version), "TryParse Result"); + Assert.IsTrue(SemanticVersion.TryParse(versionString, null, out version), "TryParse Result"); Assert.AreEqual(major, version.Major); Assert.AreEqual(minor, version.Minor); Assert.AreEqual(patch, version.Patch); @@ -49,7 +49,7 @@ public void ValidateVersionParsing(string versionString, int major, int minor, i public void ValidateInvalidVersionParsing(string versionString) { SemanticVersion version; - Assert.IsFalse(SemanticVersion.TryParse(versionString, out version), "TryParse Result"); + Assert.IsFalse(SemanticVersion.TryParse(versionString, null, out version), "TryParse Result"); } [Test] @@ -64,16 +64,16 @@ public void LegacySemVerTest() [Test] public void VersionSorting() { - SemanticVersion.Parse("1.0.0").ShouldBeGreaterThan(SemanticVersion.Parse("1.0.0-beta")); - SemanticVersion.Parse("1.0.0-beta.2").ShouldBeGreaterThan(SemanticVersion.Parse("1.0.0-beta.1")); - SemanticVersion.Parse("1.0.0-beta.1").ShouldBeLessThan(SemanticVersion.Parse("1.0.0-beta.2")); + SemanticVersion.Parse("1.0.0", null).ShouldBeGreaterThan(SemanticVersion.Parse("1.0.0-beta", null)); + SemanticVersion.Parse("1.0.0-beta.2", null).ShouldBeGreaterThan(SemanticVersion.Parse("1.0.0-beta.1", null)); + SemanticVersion.Parse("1.0.0-beta.1", null).ShouldBeLessThan(SemanticVersion.Parse("1.0.0-beta.2", null)); } [Test] public void ToStringJTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("j")); - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3-beta.4").ToString("j")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("j")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("j")); var fullSemVer = new SemanticVersion { Major = 1, @@ -93,8 +93,8 @@ public void ToStringJTests() [Test] public void ToStringSTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("s")); - Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4").ToString("s")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("s")); + Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("s")); var fullSemVer = new SemanticVersion { Major = 1, @@ -114,8 +114,8 @@ public void ToStringSTests() [Test] public void ToStringLTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("l")); - Assert.AreEqual("1.2.3-beta4", SemanticVersion.Parse("1.2.3-beta.4").ToString("l")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("l")); + Assert.AreEqual("1.2.3-beta4", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("l")); var fullSemVer = new SemanticVersion { Major = 1, @@ -135,8 +135,8 @@ public void ToStringLTests() [Test] public void ToStringLPTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("lp")); - Assert.AreEqual("1.2.3-beta0004", SemanticVersion.Parse("1.2.3-beta.4").ToString("lp")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("lp")); + Assert.AreEqual("1.2.3-beta0004", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("lp")); var fullSemVer = new SemanticVersion { Major = 1, @@ -156,9 +156,9 @@ public void ToStringLPTests() [Test] public void ToStringTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString()); - Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4").ToString()); - Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4+5").ToString()); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString()); + Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4", null).ToString()); + Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4+5", null).ToString()); var fullSemVer = new SemanticVersion { Major = 1, @@ -178,9 +178,9 @@ public void ToStringTests() [Test] public void ToStringFTests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("f")); - Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4").ToString("f")); - Assert.AreEqual("1.2.3-beta.4+5", SemanticVersion.Parse("1.2.3-beta.4+5").ToString("f")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("f")); + Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("f")); + Assert.AreEqual("1.2.3-beta.4+5", SemanticVersion.Parse("1.2.3-beta.4+5", null).ToString("f")); var fullSemVer = new SemanticVersion { Major = 1, @@ -200,9 +200,9 @@ public void ToStringFTests() [Test] public void ToStringITests() { - Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3").ToString("i")); - Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4").ToString("i")); - Assert.AreEqual("1.2.3-beta.4+5", SemanticVersion.Parse("1.2.3-beta.4+5").ToString("i")); + Assert.AreEqual("1.2.3-beta.4", SemanticVersion.Parse("1.2.3-beta.4", null).ToString("i")); + Assert.AreEqual("1.2.3", SemanticVersion.Parse("1.2.3", null).ToString("i")); + Assert.AreEqual("1.2.3-beta.4+5", SemanticVersion.Parse("1.2.3-beta.4+5", null).ToString("i")); var fullSemVer = new SemanticVersion { Major = 1, diff --git a/GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs b/GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs index fd841647e7..fc52a919a0 100644 --- a/GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs +++ b/GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs @@ -35,7 +35,7 @@ protected SemanticVersion FindVersion( context.CurrentBranch.Name, context.CurrentCommit.Sha, context.CurrentCommit.When()) }; - semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository); + semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return semanticVersion; } diff --git a/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs index c704f924fa..16192f4aad 100644 --- a/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/DevelopVersionFinder.cs @@ -30,7 +30,7 @@ public SemanticVersion FindVersion(GitVersionContext context) BuildMetaData = new SemanticVersionBuildMetaData(numberOfCommitsSinceRelease, context.CurrentBranch.Name,tip.Sha,tip.When()), }; - semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository); + semanticVersion.OverrideVersionManuallyIfNeeded(context.Repository, context.Configuration); return semanticVersion; } diff --git a/GitVersionCore/GitFlow/BranchFinders/RecentTagVersionExtractor.cs b/GitVersionCore/GitFlow/BranchFinders/RecentTagVersionExtractor.cs index c0f13a4226..ab96b98dc2 100644 --- a/GitVersionCore/GitFlow/BranchFinders/RecentTagVersionExtractor.cs +++ b/GitVersionCore/GitFlow/BranchFinders/RecentTagVersionExtractor.cs @@ -8,7 +8,7 @@ class RecentTagVersionExtractor { internal static SemanticVersionPreReleaseTag RetrieveMostRecentOptionalTagVersion(GitVersionContext context, ShortVersion matchVersion) { - var tagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(matchVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name)); + var tagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(context.Configuration, matchVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)); return RetrieveMostRecentOptionalTagVersion(context, tagsInDescendingOrder.ToList()); } @@ -17,7 +17,7 @@ internal static SemanticVersionPreReleaseTag RetrieveMostRecentOptionalTagVersio if (applicableTagsInDescendingOrder.Any()) { var taggedCommit = applicableTagsInDescendingOrder.First().Target; - var preReleaseVersion = applicableTagsInDescendingOrder.Select(tag => SemanticVersion.Parse(tag.Name)).FirstOrDefault(); + var preReleaseVersion = applicableTagsInDescendingOrder.Select(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)).FirstOrDefault(); if (preReleaseVersion != null) { if (taggedCommit != context.CurrentCommit) diff --git a/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs index 060c6864f9..3649b22392 100644 --- a/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/ReleaseVersionFinder.cs @@ -11,8 +11,8 @@ public SemanticVersion FindVersion(GitVersionContext context) var shortVersion = ShortVersionParser.Parse(versionString); EnsureVersionIsValid(shortVersion, context.CurrentBranch); - - var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name)).ToList(); + + var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(context.Configuration, shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)).ToList(); var numberOfCommitsSinceLastTagOrBranchPoint = BranchCommitDifferenceFinder.NumberOfCommitsSinceLastTagOrBranchPoint(context, applicableTagsInDescendingOrder, BranchType.Release, "develop"); var semanticVersionPreReleaseTag = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, applicableTagsInDescendingOrder) ?? context.Configuration.ReleaseBranchTag + ".1"; diff --git a/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs index 256ee7753a..d17f46b5a5 100644 --- a/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs @@ -1,10 +1,11 @@ namespace GitVersion { + using GitVersion.Configuration; using LibGit2Sharp; class SupportVersionFinder { - public SemanticVersion FindVersion(IRepository repository, Commit tip) + public SemanticVersion FindVersion(IRepository repository, Commit tip, Config configuration) { foreach (var tag in repository.TagsByDate(tip)) { @@ -19,7 +20,7 @@ public SemanticVersion FindVersion(IRepository repository, Commit tip) if (MergeMessageParser.TryParse(tip, out versionFromTip)) { var semanticVersion = BuildVersion(tip, versionFromTip); - semanticVersion.OverrideVersionManuallyIfNeeded(repository); + semanticVersion.OverrideVersionManuallyIfNeeded(repository, configuration); return semanticVersion; } throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id."); diff --git a/GitVersionCore/GitFlow/GitFlowVersionFinder.cs b/GitVersionCore/GitFlow/GitFlowVersionFinder.cs index 9487664cad..297daeb717 100644 --- a/GitVersionCore/GitFlow/GitFlowVersionFinder.cs +++ b/GitVersionCore/GitFlow/GitFlowVersionFinder.cs @@ -31,7 +31,7 @@ public SemanticVersion FindVersion(GitVersionContext context) if (context.CurrentBranch.IsSupport()) { - return new SupportVersionFinder().FindVersion(context.Repository, context.CurrentCommit); + return new SupportVersionFinder().FindVersion(context.Repository, context.CurrentCommit, context.Configuration); } return new FeatureVersionFinder().FindVersion(context); diff --git a/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs b/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs index 66beb34564..264b83760d 100644 --- a/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs +++ b/GitVersionCore/GitHubFlow/GitHubFlowVersionFinder.cs @@ -6,7 +6,7 @@ public SemanticVersion FindVersion(GitVersionContext context) { var repositoryDirectory = context.Repository.Info.WorkingDirectory; var lastTaggedReleaseFinder = new LastTaggedReleaseFinder(context); - var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repositoryDirectory); + var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repositoryDirectory, context.Configuration); var nextSemverCalculator = new NextSemverCalculator(nextVersionTxtFileFinder, lastTaggedReleaseFinder, context); return new BuildNumberCalculator(nextSemverCalculator, lastTaggedReleaseFinder, context.Repository).GetBuildNumber(context); } diff --git a/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs b/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs index 0d6f7a632d..f913a1f670 100644 --- a/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs +++ b/GitVersionCore/GitHubFlow/LastTaggedReleaseFinder.cs @@ -1,7 +1,6 @@ namespace GitVersion { using System.Linq; - using System.Text.RegularExpressions; using LibGit2Sharp; public class LastTaggedReleaseFinder @@ -17,9 +16,8 @@ public bool GetVersion(out VersionTaggedCommit versionTaggedCommit) { var tags = context.Repository.Tags.Select(t => { - var match = Regex.Match(t.Name, string.Format("({0})?(?.*)", context.Configuration.TagPrefix)); SemanticVersion version; - if (SemanticVersion.TryParse(match.Groups["version"].Value, out version)) + if (SemanticVersion.TryParse(t.Name, context.Configuration.TagPrefix, out version)) { return new VersionTaggedCommit((Commit)t.Target, version); } diff --git a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs index 49b2b6077f..7a34675421 100644 --- a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs +++ b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs @@ -2,14 +2,17 @@ { using System; using System.IO; + using GitVersion.Configuration; public class NextVersionTxtFileFinder { string repositoryDirectory; + Config configuration; - public NextVersionTxtFileFinder(string repositoryDirectory) + public NextVersionTxtFileFinder(string repositoryDirectory, Config configuration) { this.repositoryDirectory = repositoryDirectory; + this.configuration = configuration; } public bool TryGetNextVersion(out SemanticVersion semanticVersion) @@ -28,7 +31,7 @@ public bool TryGetNextVersion(out SemanticVersion semanticVersion) return false; } - if (!SemanticVersion.TryParse(version, out semanticVersion)) + if (!SemanticVersion.TryParse(version, configuration.TagPrefix, out semanticVersion)) { throw new ArgumentException("Make sure you have a valid semantic version in NextVersion.txt"); } diff --git a/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs b/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs index f964ffd61a..b60e3ae2f7 100644 --- a/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs +++ b/GitVersionCore/GitHubFlow/OtherBranchVersionFinder.cs @@ -16,7 +16,7 @@ public bool FindVersion(GitVersionContext context, out SemanticVersion semanticV var shortVersion = ShortVersionParser.Parse(versionString); - var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name)).ToList(); + var applicableTagsInDescendingOrder = context.Repository.SemVerTagsRelatedToVersion(context.Configuration, shortVersion).OrderByDescending(tag => SemanticVersion.Parse(tag.Name, context.Configuration.TagPrefix)).ToList(); var nbHotfixCommits = BranchCommitDifferenceFinder.NumberOfCommitsSinceLastTagOrBranchPoint(context, applicableTagsInDescendingOrder, BranchType.Unknown, "master"); var semanticVersionPreReleaseTag = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, applicableTagsInDescendingOrder) ?? CreateDefaultPreReleaseTag(context, versionString); diff --git a/GitVersionCore/LibGitExtensions.cs b/GitVersionCore/LibGitExtensions.cs index 36c0d31c78..a9a796b7c2 100644 --- a/GitVersionCore/LibGitExtensions.cs +++ b/GitVersionCore/LibGitExtensions.cs @@ -4,6 +4,7 @@ namespace GitVersion using System.Collections.Generic; using System.IO; using System.Linq; + using GitVersion.Configuration; using LibGit2Sharp; static class LibGitExtensions @@ -39,12 +40,12 @@ public static IEnumerable TagsByDate(this IRepository repository, Commit co }); } - public static IEnumerable SemVerTagsRelatedToVersion(this IRepository repository, ShortVersion version) + public static IEnumerable SemVerTagsRelatedToVersion(this IRepository repository, Config configuration, ShortVersion version) { foreach (var tag in repository.Tags) { SemanticVersion tagVersion; - if (SemanticVersion.TryParse(tag.Name, out tagVersion)) + if (SemanticVersion.TryParse(tag.Name, configuration.TagPrefix, out tagVersion)) { if (version.Major == tagVersion.Major && version.Minor == tagVersion.Minor && diff --git a/GitVersionCore/SemanticVersion.cs b/GitVersionCore/SemanticVersion.cs index a90a324f4c..29815d91d6 100644 --- a/GitVersionCore/SemanticVersion.cs +++ b/GitVersionCore/SemanticVersion.cs @@ -116,17 +116,19 @@ public override int GetHashCode() return v1.CompareTo(v2) < 0; } - public static SemanticVersion Parse(string version) + public static SemanticVersion Parse(string version, string tagPrefixRegex) { SemanticVersion semanticVersion; - if (!TryParse(version, out semanticVersion)) + if (!TryParse(version, tagPrefixRegex, out semanticVersion)) throw new WarningException(string.Format("Failed to parse {0} into a Semantic Version", version)); return semanticVersion; } - public static bool TryParse(string version, out SemanticVersion semanticVersion) + public static bool TryParse(string version, string tagPrefixRegex, out SemanticVersion semanticVersion) { + var match = Regex.Match(version, string.Format("({0})?(?.*)", tagPrefixRegex)); + version = match.Groups["version"].Value; var parsed = ParseSemVer.Match(version); if (!parsed.Success) diff --git a/GitVersionCore/SemanticVersionExtensions.cs b/GitVersionCore/SemanticVersionExtensions.cs index ce12ab3e88..c1286a73b7 100644 --- a/GitVersionCore/SemanticVersionExtensions.cs +++ b/GitVersionCore/SemanticVersionExtensions.cs @@ -1,12 +1,13 @@ namespace GitVersion { + using GitVersion.Configuration; using LibGit2Sharp; public static class SemanticVersionExtensions { - public static void OverrideVersionManuallyIfNeeded(this SemanticVersion version, IRepository repository) + public static void OverrideVersionManuallyIfNeeded(this SemanticVersion version, IRepository repository, Config configuration) { - var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repository.GetRepositoryDirectory()); + var nextVersionTxtFileFinder = new NextVersionTxtFileFinder(repository.GetRepositoryDirectory(), configuration); SemanticVersion manualNextVersion ; if (nextVersionTxtFileFinder.TryGetNextVersion(out manualNextVersion)) { From b7e84be052ad1891ea4df570634c8684e7ae4404 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sun, 16 Nov 2014 17:26:17 +0000 Subject: [PATCH 16/17] Fixed remaining issue --- GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs index 2549009189..d39a36936f 100644 --- a/GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/HotfixVersionFinder.cs @@ -26,7 +26,7 @@ public SemanticVersion FindVersion(GitVersionContext context) static string GetSemanticVersionPreReleaseTag(GitVersionContext context, ShortVersion shortVersion, int nbHotfixCommits) { - var semanticVersionPreReleaseTag = "beta.1"; + var semanticVersionPreReleaseTag = context.Configuration.ReleaseBranchTag + ".1"; var tagVersion = RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, shortVersion); if (tagVersion != null) { From 9264a60803a103eaa9acc1a50862f0343e6999da Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Sun, 16 Nov 2014 22:31:41 +0000 Subject: [PATCH 17/17] PR feedback changes --- GitVersionCore.Tests/ConfigReaderTests.cs | 1 - .../Fixtures/BaseGitFlowRepositoryFixture.cs | 2 +- .../Fixtures/CommitCountingRepoFixture.cs | 2 +- .../Fixtures/EmptyRepositoryFixture.cs | 2 +- .../Fixtures/RepositoryFixtureBase.cs | 1 - .../GitVersionCore.Tests.csproj | 68 ------------------- .../GitVersionCore.Tests.v2.ncrunchproject | 2 +- .../GitFlow/DevelopScenarios.cs | 2 +- .../GitFlow/ReleaseBranchTests.cs | 2 +- .../IntegrationTests/GitFlow/WikiScenarios.cs | 2 +- .../GitHubFlow/MasterTests.cs | 2 +- .../GitHubFlow/OtherBranchTests.cs | 2 +- .../GitHubFlow/ReleaseBranchTests.cs | 2 +- .../JsonVersionBuilderTests.cs | 1 - .../LastVersionOnMasterFinderTests.cs | 1 - GitVersionCore.Tests/VariableProviderTests.cs | 1 - GitVersionCore/Configuration/Config.cs | 2 +- GitVersionCore/Configuration/ConfigReader.cs | 2 +- .../Configuration/ConfigurationProvider.cs | 6 +- .../BranchFinders/SupportVersionFinder.cs | 1 - .../GitHubFlow/NextVersionTxtFileFinder.cs | 1 - GitVersionCore/GitVersionContext.cs | 1 - GitVersionCore/LibGitExtensions.cs | 1 - .../OutputFormatters/BuildOutputFormatter.cs | 1 - .../OutputVariables/VariableProvider.cs | 1 - GitVersionCore/SemanticVersionExtensions.cs | 1 - .../ExecCmdLineArgumentTest.cs | 2 +- GitVersionExe.Tests/MsBuildProjectArgTest.cs | 2 +- .../PullRequestInTeamCityTest.cs | 1 - GitVersionExe/Program.cs | 1 - .../AssemblyInfoBuilderTests.cs | 1 - .../BranchFinders/DevelopTests.cs | 1 - .../BranchFinders/FeatureBranchTests.cs | 1 - .../BranchFinders/PullBranchTests.cs | 1 - .../BranchFinders/ReleaseTests.cs | 1 - GitVersionTask.Tests/GetVersionTaskTests.cs | 1 - .../GitFlow/GitFlowVersionFinderTests.cs | 1 - GitVersionTask.Tests/GitHelperTests.cs | 1 - .../MergedBranchesWithVersionFinderTests.cs | 1 - GitVersionTask.Tests/IntegrationTests.cs | 1 - .../VersionAndBranchFinderTests.cs | 2 +- .../AssemblyInfoBuilder.cs | 1 - .../AssemblyInfoBuilder/UpdateAssemblyInfo.cs | 1 - GitVersionTask/GetVersion.cs | 1 - GitVersionTask/VersionAndBranchFinder.cs | 1 - GitVersionTask/VersionCache.cs | 1 - GitVersionTask/WriteVersionInfoToBuildLog.cs | 1 - 47 files changed, 17 insertions(+), 117 deletions(-) diff --git a/GitVersionCore.Tests/ConfigReaderTests.cs b/GitVersionCore.Tests/ConfigReaderTests.cs index 7b964d1040..5bd98f737e 100644 --- a/GitVersionCore.Tests/ConfigReaderTests.cs +++ b/GitVersionCore.Tests/ConfigReaderTests.cs @@ -1,6 +1,5 @@ using System.IO; using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; using Shouldly; diff --git a/GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs b/GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs index c911c3b196..ad7b5f43d7 100644 --- a/GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs +++ b/GitVersionCore.Tests/Fixtures/BaseGitFlowRepositoryFixture.cs @@ -1,6 +1,6 @@ using System; using System.IO; -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture diff --git a/GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs b/GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs index 3e798a6aa4..eb86f9d7e8 100644 --- a/GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs +++ b/GitVersionCore.Tests/Fixtures/CommitCountingRepoFixture.cs @@ -1,6 +1,6 @@ using System; using System.IO; -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; public class CommitCountingRepoFixture : RepositoryFixtureBase diff --git a/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs b/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs index cac9cb2c4e..dc88f61b55 100644 --- a/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs +++ b/GitVersionCore.Tests/Fixtures/EmptyRepositoryFixture.cs @@ -1,5 +1,5 @@ using System; -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; public class EmptyRepositoryFixture : RepositoryFixtureBase diff --git a/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs b/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs index 20cf020f1d..efb6daa23e 100644 --- a/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs +++ b/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs @@ -1,6 +1,5 @@ using System; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using Shouldly; diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.csproj b/GitVersionCore.Tests/GitVersionCore.Tests.csproj index 65f3b2e036..83965c856e 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.csproj +++ b/GitVersionCore.Tests/GitVersionCore.Tests.csproj @@ -94,70 +94,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -168,10 +104,6 @@ - - - - diff --git a/GitVersionCore.Tests/GitVersionCore.Tests.v2.ncrunchproject b/GitVersionCore.Tests/GitVersionCore.Tests.v2.ncrunchproject index e8a87eec3c..1be4f23838 100644 --- a/GitVersionCore.Tests/GitVersionCore.Tests.v2.ncrunchproject +++ b/GitVersionCore.Tests/GitVersionCore.Tests.v2.ncrunchproject @@ -22,6 +22,6 @@ AutoDetect STA x86 - ..\Packages\LibGit2Sharp.0.19.0.0\lib\net40\NativeBinaries\**.* + ..\Packages\LibGit2Sharp.0.19.0.0\lib\net40\NativeBinaries\**.*;Resources\**.* PostBuildEventDisabled \ No newline at end of file diff --git a/GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs index 6f89553ad5..9b97b1027f 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitFlow/DevelopScenarios.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs index c3625d357d..016705aa8e 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitFlow/ReleaseBranchTests.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs b/GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs index bdb3e6bc01..2e27189f61 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitFlow/WikiScenarios.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs index e621bc3ca4..864ad7423c 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/MasterTests.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs index 58973bb241..11b3893fea 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/OtherBranchTests.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs index 4418205a43..d6fe14854c 100644 --- a/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs +++ b/GitVersionCore.Tests/IntegrationTests/GitHubFlow/ReleaseBranchTests.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionCore.Tests/JsonVersionBuilderTests.cs b/GitVersionCore.Tests/JsonVersionBuilderTests.cs index 4051c69431..cc25171a9d 100644 --- a/GitVersionCore.Tests/JsonVersionBuilderTests.cs +++ b/GitVersionCore.Tests/JsonVersionBuilderTests.cs @@ -1,7 +1,6 @@ using System; using ApprovalTests; using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; [TestFixture] diff --git a/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs b/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs index 60eeeb8de8..0dc22c4a5d 100644 --- a/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs +++ b/GitVersionCore.Tests/LastVersionOnMasterFinderTests.cs @@ -1,6 +1,5 @@ using System; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using Shouldly; diff --git a/GitVersionCore.Tests/VariableProviderTests.cs b/GitVersionCore.Tests/VariableProviderTests.cs index 7d73b64211..353bbe0950 100644 --- a/GitVersionCore.Tests/VariableProviderTests.cs +++ b/GitVersionCore.Tests/VariableProviderTests.cs @@ -1,6 +1,5 @@ using System; using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; using Shouldly; diff --git a/GitVersionCore/Configuration/Config.cs b/GitVersionCore/Configuration/Config.cs index 0a13d06e5d..b056549a82 100644 --- a/GitVersionCore/Configuration/Config.cs +++ b/GitVersionCore/Configuration/Config.cs @@ -1,4 +1,4 @@ -namespace GitVersion.Configuration +namespace GitVersion { using YamlDotNet.Serialization; diff --git a/GitVersionCore/Configuration/ConfigReader.cs b/GitVersionCore/Configuration/ConfigReader.cs index 99a9f63cd6..7c2f3a6022 100644 --- a/GitVersionCore/Configuration/ConfigReader.cs +++ b/GitVersionCore/Configuration/ConfigReader.cs @@ -2,7 +2,7 @@ using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; -namespace GitVersion.Configuration +namespace GitVersion { public class ConfigReader { diff --git a/GitVersionCore/Configuration/ConfigurationProvider.cs b/GitVersionCore/Configuration/ConfigurationProvider.cs index 0717b7ecf1..449789c5df 100644 --- a/GitVersionCore/Configuration/ConfigurationProvider.cs +++ b/GitVersionCore/Configuration/ConfigurationProvider.cs @@ -1,4 +1,4 @@ -namespace GitVersion.Configuration +namespace GitVersion { using System.IO; @@ -11,9 +11,7 @@ public static Config Provide(string gitDirectory) { using (var reader = File.OpenText(configFilePath)) { - { - return ConfigReader.Read(reader); - } + return ConfigReader.Read(reader); } } diff --git a/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs b/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs index d17f46b5a5..db84d4506b 100644 --- a/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs +++ b/GitVersionCore/GitFlow/BranchFinders/SupportVersionFinder.cs @@ -1,6 +1,5 @@ namespace GitVersion { - using GitVersion.Configuration; using LibGit2Sharp; class SupportVersionFinder diff --git a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs index 7a34675421..58b36ecfc3 100644 --- a/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs +++ b/GitVersionCore/GitHubFlow/NextVersionTxtFileFinder.cs @@ -2,7 +2,6 @@ { using System; using System.IO; - using GitVersion.Configuration; public class NextVersionTxtFileFinder { diff --git a/GitVersionCore/GitVersionContext.cs b/GitVersionCore/GitVersionContext.cs index 41375117d1..05e754cce0 100644 --- a/GitVersionCore/GitVersionContext.cs +++ b/GitVersionCore/GitVersionContext.cs @@ -2,7 +2,6 @@ { using System.Collections.Generic; using System.Linq; - using GitVersion.Configuration; using LibGit2Sharp; /// diff --git a/GitVersionCore/LibGitExtensions.cs b/GitVersionCore/LibGitExtensions.cs index a9a796b7c2..fd349469f7 100644 --- a/GitVersionCore/LibGitExtensions.cs +++ b/GitVersionCore/LibGitExtensions.cs @@ -4,7 +4,6 @@ namespace GitVersion using System.Collections.Generic; using System.IO; using System.Linq; - using GitVersion.Configuration; using LibGit2Sharp; static class LibGitExtensions diff --git a/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs b/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs index 1c910cadcf..e5994075be 100644 --- a/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs +++ b/GitVersionCore/OutputFormatters/BuildOutputFormatter.cs @@ -1,7 +1,6 @@ namespace GitVersion { using System.Collections.Generic; - using GitVersion.Configuration; public static class BuildOutputFormatter { diff --git a/GitVersionCore/OutputVariables/VariableProvider.cs b/GitVersionCore/OutputVariables/VariableProvider.cs index e46fb1fb63..1ffd3feb8f 100644 --- a/GitVersionCore/OutputVariables/VariableProvider.cs +++ b/GitVersionCore/OutputVariables/VariableProvider.cs @@ -2,7 +2,6 @@ { using System; using System.Collections.Generic; - using GitVersion.Configuration; public static class VariableProvider { diff --git a/GitVersionCore/SemanticVersionExtensions.cs b/GitVersionCore/SemanticVersionExtensions.cs index c1286a73b7..0cf71f9653 100644 --- a/GitVersionCore/SemanticVersionExtensions.cs +++ b/GitVersionCore/SemanticVersionExtensions.cs @@ -1,6 +1,5 @@ namespace GitVersion { - using GitVersion.Configuration; using LibGit2Sharp; public static class SemanticVersionExtensions diff --git a/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs b/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs index cd9713fad0..0fa5f15280 100644 --- a/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs +++ b/GitVersionExe.Tests/ExecCmdLineArgumentTest.cs @@ -1,5 +1,5 @@ using System.IO; -using GitVersion.Configuration; +using GitVersion; using NUnit.Framework; using Shouldly; diff --git a/GitVersionExe.Tests/MsBuildProjectArgTest.cs b/GitVersionExe.Tests/MsBuildProjectArgTest.cs index c21b08c928..c4fa4bcca7 100644 --- a/GitVersionExe.Tests/MsBuildProjectArgTest.cs +++ b/GitVersionExe.Tests/MsBuildProjectArgTest.cs @@ -1,5 +1,5 @@ using System.IO; -using GitVersion.Configuration; +using GitVersion; using NUnit.Framework; using Shouldly; diff --git a/GitVersionExe.Tests/PullRequestInTeamCityTest.cs b/GitVersionExe.Tests/PullRequestInTeamCityTest.cs index 15fdc1733b..d056a7eea4 100644 --- a/GitVersionExe.Tests/PullRequestInTeamCityTest.cs +++ b/GitVersionExe.Tests/PullRequestInTeamCityTest.cs @@ -1,6 +1,5 @@ using System; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using Shouldly; diff --git a/GitVersionExe/Program.cs b/GitVersionExe/Program.cs index 6936f5e8e6..c8b9c63b89 100644 --- a/GitVersionExe/Program.cs +++ b/GitVersionExe/Program.cs @@ -6,7 +6,6 @@ namespace GitVersion using System.IO; using System.Linq; using System.Text; - using GitVersion.Configuration; class Program { diff --git a/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs b/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs index bb778ad15b..a61561c0ce 100644 --- a/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs +++ b/GitVersionTask.Tests/AssemblyInfoBuilderTests.cs @@ -4,7 +4,6 @@ using System.Runtime.CompilerServices; using ApprovalTests; using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; using Roslyn.Compilers; using Roslyn.Compilers.CSharp; diff --git a/GitVersionTask.Tests/BranchFinders/DevelopTests.cs b/GitVersionTask.Tests/BranchFinders/DevelopTests.cs index d5a8ca77b8..2d73412448 100644 --- a/GitVersionTask.Tests/BranchFinders/DevelopTests.cs +++ b/GitVersionTask.Tests/BranchFinders/DevelopTests.cs @@ -1,7 +1,6 @@ using FluentDate; using FluentDateTimeOffset; using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; using ObjectApproval; diff --git a/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs b/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs index cf2329dfc1..de71846d3b 100644 --- a/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs +++ b/GitVersionTask.Tests/BranchFinders/FeatureBranchTests.cs @@ -1,5 +1,4 @@ using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; diff --git a/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs b/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs index 2a8f214b76..7cae7a82b9 100644 --- a/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs +++ b/GitVersionTask.Tests/BranchFinders/PullBranchTests.cs @@ -1,5 +1,4 @@ using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; diff --git a/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs b/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs index c3e2054589..d60f086a25 100644 --- a/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs +++ b/GitVersionTask.Tests/BranchFinders/ReleaseTests.cs @@ -1,6 +1,5 @@ using System; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; diff --git a/GitVersionTask.Tests/GetVersionTaskTests.cs b/GitVersionTask.Tests/GetVersionTaskTests.cs index 6e11dc36be..9c1c57280f 100644 --- a/GitVersionTask.Tests/GetVersionTaskTests.cs +++ b/GitVersionTask.Tests/GetVersionTaskTests.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using GitVersion; -using GitVersion.Configuration; using GitVersionTask; using Microsoft.Build.Framework; using NUnit.Framework; diff --git a/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs b/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs index 05f1a2b48b..b935ee3d94 100644 --- a/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs +++ b/GitVersionTask.Tests/GitFlow/GitFlowVersionFinderTests.cs @@ -1,6 +1,5 @@ using System.IO; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; using ObjectApproval; diff --git a/GitVersionTask.Tests/GitHelperTests.cs b/GitVersionTask.Tests/GitHelperTests.cs index 01b91e007a..6fc87f8836 100644 --- a/GitVersionTask.Tests/GitHelperTests.cs +++ b/GitVersionTask.Tests/GitHelperTests.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Linq; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs b/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs index b9cf088f41..643b28096f 100644 --- a/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs +++ b/GitVersionTask.Tests/GitHubFlow/MergedBranchesWithVersionFinderTests.cs @@ -1,5 +1,4 @@ using GitVersion; -using GitVersion.Configuration; using NUnit.Framework; using Shouldly; diff --git a/GitVersionTask.Tests/IntegrationTests.cs b/GitVersionTask.Tests/IntegrationTests.cs index 1da79ce2cf..63d46fb8af 100644 --- a/GitVersionTask.Tests/IntegrationTests.cs +++ b/GitVersionTask.Tests/IntegrationTests.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Linq; using GitVersion; -using GitVersion.Configuration; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionTask.Tests/VersionAndBranchFinderTests.cs b/GitVersionTask.Tests/VersionAndBranchFinderTests.cs index 0b48038001..8028558365 100644 --- a/GitVersionTask.Tests/VersionAndBranchFinderTests.cs +++ b/GitVersionTask.Tests/VersionAndBranchFinderTests.cs @@ -1,4 +1,4 @@ -using GitVersion.Configuration; +using GitVersion; using LibGit2Sharp; using NUnit.Framework; diff --git a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs index 77ebaaa209..d1e239b06f 100644 --- a/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs +++ b/GitVersionTask/AssemblyInfoBuilder/AssemblyInfoBuilder.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Text; using GitVersion; -using GitVersion.Configuration; public class AssemblyInfoBuilder { diff --git a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs index 90efc23a27..fb241a92c2 100644 --- a/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs +++ b/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs @@ -3,7 +3,6 @@ using System; using System.IO; using GitVersion; - using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger; diff --git a/GitVersionTask/GetVersion.cs b/GitVersionTask/GetVersion.cs index 8b127ac5e9..2c80c70996 100644 --- a/GitVersionTask/GetVersion.cs +++ b/GitVersionTask/GetVersion.cs @@ -2,7 +2,6 @@ { using System; using GitVersion; - using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger; diff --git a/GitVersionTask/VersionAndBranchFinder.cs b/GitVersionTask/VersionAndBranchFinder.cs index 1f70ef8de4..180696064c 100644 --- a/GitVersionTask/VersionAndBranchFinder.cs +++ b/GitVersionTask/VersionAndBranchFinder.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using GitVersion; -using GitVersion.Configuration; public static class VersionAndBranchFinder { diff --git a/GitVersionTask/VersionCache.cs b/GitVersionTask/VersionCache.cs index d36460f52d..961e8f9aba 100644 --- a/GitVersionTask/VersionCache.cs +++ b/GitVersionTask/VersionCache.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using GitVersion; -using GitVersion.Configuration; public static class VersionCache { diff --git a/GitVersionTask/WriteVersionInfoToBuildLog.cs b/GitVersionTask/WriteVersionInfoToBuildLog.cs index 6354a6d470..cad6c16bc3 100644 --- a/GitVersionTask/WriteVersionInfoToBuildLog.cs +++ b/GitVersionTask/WriteVersionInfoToBuildLog.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using GitVersion; - using GitVersion.Configuration; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using Logger = GitVersion.Logger;