Skip to content
6 changes: 4 additions & 2 deletions src/GitVersionCore/ExecuteCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 7 additions & 0 deletions src/GitVersionExe.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
6 changes: 6 additions & 0 deletions src/GitVersionExe/ArgumentParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public static Arguments ParseArguments(List<string> commandLineArguments)
continue;
}

if (name.IsSwitch("noNormalize"))
{
arguments.NoNormalize = true;
continue;
}

if (name.IsSwitch("ensureassemblyinfo"))
{
if (value.IsTrue())
Expand Down
1 change: 1 addition & 0 deletions src/GitVersionExe/Arguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public Arguments()
public bool ShowConfig;
public bool NoFetch;
public bool NoCache;
public bool NoNormalize;

public VerbosityLevel Verbosity;

Expand Down
3 changes: 2 additions & 1 deletion src/GitVersionExe/SpecifiedArgumentRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down