Skip to content

Commit 72ad9ab

Browse files
committed
clear comments, better naming, strip path from content calc
1 parent 754f93a commit 72ad9ab

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/GitVersionCore.Tests/ExecuteCoreTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public void CacheKeySameAfterReNormalizing()
2828
var targetUrl = "https://github.com/GitTools/GitVersion.git";
2929
var targetBranch = "refs/head/master";
3030
var gitPreparer = new GitPreparer(targetUrl, null, new Authentication(), false, fixture.RepositoryPath);
31-
//var cacheKey0 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);
3231
gitPreparer.Initialise(true, targetBranch);
3332
var cacheKey1 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);
3433
gitPreparer.Initialise(true, targetBranch);

src/GitVersionCore/GitVersionCacheKeyFactory.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ private static string GetGitSystemHash(GitPreparer gitPreparer, IFileSystem file
2626
var dotGitDirectory = gitPreparer.GetDotGitDirectory();
2727

2828
// traverse the directory and get a list of files, use that for GetHash
29-
var traverse = TraverseTree(Path.Combine(dotGitDirectory, "refs"));
29+
var contents = calculateDirectoryContents(Path.Combine(dotGitDirectory, "refs"));
3030

31-
return GetHash(traverse.ToArray());
31+
return GetHash(contents.ToArray());
3232
}
3333

34-
// lifted from https://msdn.microsoft.com/en-us/library/bb513869.aspx
35-
public static List<string> TraverseTree(string root)
34+
// based on https://msdn.microsoft.com/en-us/library/bb513869.aspx
35+
private static List<string> calculateDirectoryContents(string root)
3636
{
37-
var result = new List<string> { root };
37+
var result = new List<string>();
3838

3939
// Data structure to hold names of subfolders to be
4040
// examined for files.
41-
var dirs = new Stack<string>(20);
41+
var dirs = new Stack<string>();
4242

4343
if (!Directory.Exists(root))
4444
{
@@ -104,7 +104,6 @@ public static List<string> TraverseTree(string root)
104104
var fi = new FileInfo(file);
105105
result.Add(fi.Name);
106106
result.Add(File.ReadAllText(file));
107-
//Logger.WriteInfo(string.Format("{0}: {1}, {2}", fi.Name, fi.Length, fi.CreationTime));
108107
}
109108
catch (IOException e)
110109
{

0 commit comments

Comments
 (0)