From fb2e7bbdf0a643ff72f979b1273e5d6e7e7b2c96 Mon Sep 17 00:00:00 2001 From: "Bankers, R.H.M. (Rob)" Date: Sat, 3 Aug 2019 18:58:00 +0200 Subject: [PATCH 1/4] Add -noNormalize option to disable normalize function --- src/GitVersionCore/ExecuteCore.cs | 6 ++++-- src/GitVersionExe.Tests/ArgumentParserTests.cs | 7 +++++++ src/GitVersionExe/ArgumentParser.cs | 6 ++++++ src/GitVersionExe/Arguments.cs | 1 + src/GitVersionExe/SpecifiedArgumentRunner.cs | 3 ++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/GitVersionCore/ExecuteCore.cs b/src/GitVersionCore/ExecuteCore.cs index 5723a95cd5..19585012e1 100644 --- a/src/GitVersionCore/ExecuteCore.cs +++ b/src/GitVersionCore/ExecuteCore.cs @@ -18,15 +18,17 @@ public ExecuteCore(IFileSystem fileSystem, ConfigFileLocator configFileLocator = gitVersionCache = new GitVersionCache(fileSystem); } - public VersionVariables ExecuteGitVersion(string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string workingDirectory, string commitId, Config overrideConfig = null, bool noCache = false) + public VersionVariables ExecuteGitVersion(string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string workingDirectory, string commitId, Config overrideConfig = null, bool noCache = false, bool noNormalize = false) { // Normalise if we are running on build server var applicableBuildServers = BuildServerList.GetApplicableBuildServers(); var buildServer = applicableBuildServers.FirstOrDefault(); + bool normaliseGitDirectory = !noNormalize && (buildServer != null); var fetch = noFetch || (buildServer != null && buildServer.PreventFetch()); var shouldCleanUpRemotes = buildServer != null && buildServer.ShouldCleanUpRemotes(); var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, fetch, workingDirectory); - gitPreparer.Initialise(buildServer != null, ResolveCurrentBranch(buildServer, targetBranch, !string.IsNullOrWhiteSpace(dynamicRepositoryLocation)), shouldCleanUpRemotes); + + gitPreparer.Initialise(normaliseGitDirectory, ResolveCurrentBranch(buildServer, targetBranch, !string.IsNullOrWhiteSpace(dynamicRepositoryLocation)), shouldCleanUpRemotes); var dotGitDirectory = gitPreparer.GetDotGitDirectory(); var projectRoot = gitPreparer.GetProjectRootDirectory(); diff --git a/src/GitVersionExe.Tests/ArgumentParserTests.cs b/src/GitVersionExe.Tests/ArgumentParserTests.cs index da6ea13b82..4609d45893 100644 --- a/src/GitVersionExe.Tests/ArgumentParserTests.cs +++ b/src/GitVersionExe.Tests/ArgumentParserTests.cs @@ -300,6 +300,13 @@ public void Nofetch_true_when_defined() arguments.NoFetch.ShouldBe(true); } + [Test] + public void Nonormilize_true_when_defined() + { + var arguments = ArgumentParser.ParseArguments("-noNormalize"); + arguments.NoNormalize.ShouldBe(true); + } + [Test] public void Other_arguments_can_be_parsed_before_nofetch() { diff --git a/src/GitVersionExe/ArgumentParser.cs b/src/GitVersionExe/ArgumentParser.cs index b84af88db0..bfd68ffac9 100644 --- a/src/GitVersionExe/ArgumentParser.cs +++ b/src/GitVersionExe/ArgumentParser.cs @@ -267,6 +267,12 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } + if (name.IsSwitch("noNormalize")) + { + arguments.NoNormalize = true; + continue; + } + if (name.IsSwitch("ensureassemblyinfo")) { if (value.IsTrue()) diff --git a/src/GitVersionExe/Arguments.cs b/src/GitVersionExe/Arguments.cs index 62834e2154..2ea35d730b 100644 --- a/src/GitVersionExe/Arguments.cs +++ b/src/GitVersionExe/Arguments.cs @@ -49,6 +49,7 @@ public Arguments() public bool ShowConfig; public bool NoFetch; public bool NoCache; + public bool NoNormalize; public VerbosityLevel Verbosity; diff --git a/src/GitVersionExe/SpecifiedArgumentRunner.cs b/src/GitVersionExe/SpecifiedArgumentRunner.cs index 138ec48bf2..149b2d0abb 100644 --- a/src/GitVersionExe/SpecifiedArgumentRunner.cs +++ b/src/GitVersionExe/SpecifiedArgumentRunner.cs @@ -41,9 +41,10 @@ public static void Run(Arguments arguments, IFileSystem fileSystem) var commitId = arguments.CommitId; var overrideConfig = arguments.HasOverrideConfig ? arguments.OverrideConfig : null; var noCache = arguments.NoCache; + bool noNormalize = arguments.NoNormalize; var executeCore = new ExecuteCore(fileSystem, arguments.ConfigFileLocator); - var variables = executeCore.ExecuteGitVersion(targetUrl, dynamicRepositoryLocation, authentication, targetBranch, noFetch, targetPath, commitId, overrideConfig, noCache); + var variables = executeCore.ExecuteGitVersion(targetUrl, dynamicRepositoryLocation, authentication, targetBranch, noFetch, targetPath, commitId, overrideConfig, noCache, noNormalize); if (arguments.Output == OutputType.BuildServer) { From 9cc6913a2b608da37001f3dd8eb0991008cff342 Mon Sep 17 00:00:00 2001 From: "Bankers, R.H.M. (Rob)" Date: Sun, 4 Aug 2019 10:25:47 +0200 Subject: [PATCH 2/4] Add nonormalize to help text --- src/GitVersionExe.Tests/ArgumentParserTests.cs | 2 +- src/GitVersionExe/ArgumentParser.cs | 2 +- src/GitVersionExe/HelpWriter.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/GitVersionExe.Tests/ArgumentParserTests.cs b/src/GitVersionExe.Tests/ArgumentParserTests.cs index 4609d45893..44d1cf5e0c 100644 --- a/src/GitVersionExe.Tests/ArgumentParserTests.cs +++ b/src/GitVersionExe.Tests/ArgumentParserTests.cs @@ -303,7 +303,7 @@ public void Nofetch_true_when_defined() [Test] public void Nonormilize_true_when_defined() { - var arguments = ArgumentParser.ParseArguments("-noNormalize"); + var arguments = ArgumentParser.ParseArguments("-nonormalize"); arguments.NoNormalize.ShouldBe(true); } diff --git a/src/GitVersionExe/ArgumentParser.cs b/src/GitVersionExe/ArgumentParser.cs index bfd68ffac9..32baeed920 100644 --- a/src/GitVersionExe/ArgumentParser.cs +++ b/src/GitVersionExe/ArgumentParser.cs @@ -267,7 +267,7 @@ public static Arguments ParseArguments(List commandLineArguments) continue; } - if (name.IsSwitch("noNormalize")) + if (name.IsSwitch("nonormalize")) { arguments.NoNormalize = true; continue; diff --git a/src/GitVersionExe/HelpWriter.cs b/src/GitVersionExe/HelpWriter.cs index 0201422449..91f9bd4d03 100644 --- a/src/GitVersionExe/HelpWriter.cs +++ b/src/GitVersionExe/HelpWriter.cs @@ -38,6 +38,7 @@ path The directory containing .git. If not defined current directory /overrideconfig Overrides GitVersion config values inline (semicolon-separated key value pairs e.g. /overrideconfig tag-prefix=Foo) Currently supported config overrides: tag-prefix /nocache Bypasses the cache, result will not be written to the cache. + /nonormalize Disables normalize step on a build server. # AssemblyInfo updating /updateassemblyinfo From 46326ce753d2c5243abcdaf0e9f5343846cfaaec Mon Sep 17 00:00:00 2001 From: "Bankers, R.H.M. (Rob)" Date: Wed, 14 Aug 2019 09:46:48 +0200 Subject: [PATCH 3/4] Added documentation in the build-server-support.md for the nonormalize option --- docs/build-server-support/build-server-support.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/build-server-support/build-server-support.md b/docs/build-server-support/build-server-support.md index 80c39c49c4..503c8abab9 100644 --- a/docs/build-server-support/build-server-support.md +++ b/docs/build-server-support/build-server-support.md @@ -11,8 +11,10 @@ GitVersion has support for quite a few build servers out of the box. Currently w - [TeamCity](build-server/teamcity.md) - [Team Build (TFS)](build-server/teambuild.md) - [TFS Build vNext](build-server/tfs-build-vnext.md) - + When GitVersion.exe is run with the `/output buildserver` flag instead of outputting Json it will export variables to the current build server. For instance if you are running in TeamCity after you run `GitVersion /output buildserver` you will have the `%system.GitVersion.SemVer%` available for you to use When running in MSBuild either from the [MSBuild Task](/usage/msbuild-task) or by using the `/proj myproject.sln` parameter, GitVersion will make the MSBuild variables available in the format `$(GitVersion_SemVer)`. + +Standard GitVersion.exe normalize the branches if there is a build server detected. This behavior can be disabled with the /nonormalize option. From 9c2d408c3ca7c9f0f1e1703aff7a6e7c625ce462 Mon Sep 17 00:00:00 2001 From: Bankers88 Date: Fri, 16 Aug 2019 09:50:51 +0200 Subject: [PATCH 4/4] Update docs/build-server-support/build-server-support.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Asbjørn Ulsberg --- docs/build-server-support/build-server-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build-server-support/build-server-support.md b/docs/build-server-support/build-server-support.md index 503c8abab9..de92152a18 100644 --- a/docs/build-server-support/build-server-support.md +++ b/docs/build-server-support/build-server-support.md @@ -17,4 +17,4 @@ For instance if you are running in TeamCity after you run `GitVersion /output bu When running in MSBuild either from the [MSBuild Task](/usage/msbuild-task) or by using the `/proj myproject.sln` parameter, GitVersion will make the MSBuild variables available in the format `$(GitVersion_SemVer)`. -Standard GitVersion.exe normalize the branches if there is a build server detected. This behavior can be disabled with the /nonormalize option. +Standard GitVersion.exe normalize the branches if there is a build server detected. This behavior can be disabled with the `/nonormalize` option.