diff --git a/docs/build-server-support/build-server-support.md b/docs/build-server-support/build-server-support.md index 80c39c49c4..de92152a18 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. 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..44d1cf5e0c 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..32baeed920 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/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 diff --git a/src/GitVersionExe/SpecifiedArgumentRunner.cs b/src/GitVersionExe/SpecifiedArgumentRunner.cs index 90a983508c..b73b075891 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) {