Skip to content

Commit 5915968

Browse files
committed
Small changes based on feedback
1 parent 90a22d4 commit 5915968

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

GitVersionCore/ExecuteCore.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ public static class ExecuteCore
99
public static VersionVariables ExecuteGitVersion(IFileSystem fileSystem, string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string workingDirectory, string commitId)
1010
{
1111
// Normalise if we are running on build server
12-
var normaliseGitDirectory = BuildServerList.GetApplicableBuildServers().Any();
13-
var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, targetBranch, noFetch, workingDirectory, normaliseGitDirectory);
14-
gitPreparer.Initialise();
12+
var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, targetBranch, noFetch, workingDirectory);
13+
gitPreparer.Initialise(BuildServerList.GetApplicableBuildServers().Any());
1514
var dotGitDirectory = gitPreparer.GetDotGitDirectory();
1615
var projectRoot = gitPreparer.GetProjectRootDirectory();
1716
Logger.WriteInfo(string.Format("Project root is: " + projectRoot));

GitVersionCore/GitPreparer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ public class GitPreparer
1313
string targetBranch;
1414
bool noFetch;
1515
string targetPath;
16-
readonly bool normaliseGitDirectory;
1716

18-
public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string targetPath, bool normaliseGitDirectory)
17+
public GitPreparer(string targetUrl, string dynamicRepositoryLocation, Authentication authentication, string targetBranch, bool noFetch, string targetPath)
1918
{
2019
this.targetUrl = targetUrl;
2120
this.dynamicRepositoryLocation = dynamicRepositoryLocation;
2221
this.authentication = authentication;
2322
this.targetBranch = targetBranch;
2423
this.noFetch = noFetch;
2524
this.targetPath = targetPath;
26-
this.normaliseGitDirectory = normaliseGitDirectory;
2725
}
2826

2927
public bool IsDynamicGitRepository
@@ -33,7 +31,7 @@ public bool IsDynamicGitRepository
3331

3432
public string DynamicGitRepositoryPath { get; private set; }
3533

36-
public void Initialise()
34+
public void Initialise(bool normaliseGitDirectory)
3735
{
3836
if (string.IsNullOrWhiteSpace(targetUrl))
3937
{

GitVersionExe.Tests/GitPreparerTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public void WorksCorrectlyWithRemoteRepository(string branchName, string expecte
5555
arguments.TargetBranch = branchName;
5656
}
5757

58-
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath, false);
59-
gitPreparer.Initialise();
58+
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath);
59+
gitPreparer.Initialise(false);
6060
dynamicRepositoryPath = gitPreparer.GetDotGitDirectory();
6161

6262
gitPreparer.IsDynamicGitRepository.ShouldBe(true);
@@ -100,12 +100,12 @@ public void UpdatesExistingDynamicRepository()
100100
TargetBranch = "master"
101101
};
102102

103-
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath, false);
104-
gitPreparer.Initialise();
103+
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath);
104+
gitPreparer.Initialise(false);
105105
dynamicRepositoryPath = gitPreparer.GetDotGitDirectory();
106106

107107
var newCommit = mainRepositoryFixture.Repository.MakeACommit();
108-
gitPreparer.Initialise();
108+
gitPreparer.Initialise(false);
109109

110110
using (var repository = new Repository(dynamicRepositoryPath))
111111
{
@@ -147,8 +147,8 @@ public void PicksAnotherDirectoryNameWhenDynamicRepoFolderTaken()
147147
TargetUrl = fixture.RepositoryPath
148148
};
149149

150-
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath, false);
151-
gitPreparer.Initialise();
150+
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath);
151+
gitPreparer.Initialise(false);
152152

153153
gitPreparer.IsDynamicGitRepository.ShouldBe(true);
154154
gitPreparer.DynamicGitRepositoryPath.ShouldBe(expectedDynamicRepoLocation + "_1\\.git");
@@ -174,7 +174,7 @@ public void WorksCorrectlyWithLocalRepository()
174174
TargetPath = tempDir
175175
};
176176

177-
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath, false);
177+
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath);
178178
var dynamicRepositoryPath = gitPreparer.GetDotGitDirectory();
179179

180180
dynamicRepositoryPath.ShouldBe(null);
@@ -184,8 +184,8 @@ public void WorksCorrectlyWithLocalRepository()
184184
[Test]
185185
public void UsesGitVersionConfigWhenCreatingDynamicRepository()
186186
{
187-
string localRepoPath = PathHelper.GetTempPath();
188-
string repoBasePath = Path.GetDirectoryName(PathHelper.GetTempPath());
187+
var localRepoPath = PathHelper.GetTempPath();
188+
var repoBasePath = Path.GetDirectoryName(PathHelper.GetTempPath());
189189
Directory.CreateDirectory(localRepoPath);
190190

191191
try

0 commit comments

Comments
 (0)