private void ParseEntries(IDictionary <string, GitObject> entries, Tree treeInfo, string commit)
        {
            var treesToDescend = new Queue <Tree>(new[] { treeInfo });

            while (treesToDescend.Any())
            {
                var currentTree = treesToDescend.Dequeue();
                foreach (var item in currentTree)
                {
                    if (item.TargetType == TreeEntryTargetType.Tree)
                    {
                        treesToDescend.Enqueue((Tree)item.Target);
                    }
                    var path = item.Path.Replace('\\', '/');
                    entries[path] = new GitObject
                    {
                        Mode       = item.Mode,
                        Sha        = item.Target.Sha,
                        ObjectType = item.TargetType,
                        Path       = path,
                        Commit     = commit
                    };
                }
            }
        }
Example #2
0
        private GitObject Lookup(string pathInGitRepo)
        {
            if (_initialTree.ContainsKey(pathInGitRepo))
                return _initialTree[pathInGitRepo];

            var fullPath = pathInGitRepo;
            var splitResult = SplitDirnameFilename.Match(pathInGitRepo);
            if (splitResult.Success)
            {

                var dirName = splitResult.Groups["dir"].Value;
                var fileName = splitResult.Groups["file"].Value;
                fullPath = Lookup(dirName).Path + "/" + fileName;
            }
            _initialTree[fullPath] = new GitObject { Path = fullPath };
            return _initialTree[fullPath];
        }
Example #3
0
        private GitObject Lookup(string pathInGitRepo)
        {
            GitObject result;
            if (_initialTree.TryGetValue(pathInGitRepo, out result))
                return result;

            var fullPath = pathInGitRepo;
            var splitResult = SplitDirnameFilename.Match(pathInGitRepo);
            if (splitResult.Success)
            {
                var dirName = splitResult.Groups["dir"].Value;
                var fileName = splitResult.Groups["file"].Value;
                fullPath = Lookup(dirName).Path + "/" + fileName;
            }
            result = new GitObject { Path = fullPath };
            _initialTree[fullPath] = result;
            return result;
        }
Example #4
0
        private string UpdateToMatchExtantCasing(string pathInGitRepo, IDictionary <string, GitObject> initialTree)
        {
            if (initialTree.ContainsKey(pathInGitRepo))
            {
                return(initialTree[pathInGitRepo].Path);
            }

            var fullPath    = pathInGitRepo;
            var splitResult = SplitDirnameFilename.Match(pathInGitRepo);

            if (splitResult.Success)
            {
                var dirName  = splitResult.Groups["dir"].Value;
                var fileName = splitResult.Groups["file"].Value;
                fullPath = UpdateToMatchExtantCasing(dirName, initialTree) + "/" + fileName;
            }
            initialTree[fullPath] = new GitObject {
                Path = fullPath
            };
            return(fullPath);
        }
Example #5
0
 private void ParseEntries(IDictionary<string, GitObject> entries, Tree treeInfo, string commit)
 {
     var treesToDescend = new Queue<Tree>(new[] {treeInfo});
     while (treesToDescend.Any())
     {
         var currentTree = treesToDescend.Dequeue();
         foreach (var item in currentTree)
         {
             if (item.TargetType == TreeEntryTargetType.Tree)
             {
                 treesToDescend.Enqueue((Tree)item.Target);
             }
             var path = item.Path.Replace('\\', '/');
             entries[path] = new GitObject
             {
                 Mode = item.Mode,
                 Sha = item.Target.Sha,
                 ObjectType = item.TargetType,
                 Path = path,
                 Commit = commit
             };
         }
     }
 }
Example #6
0
        private string UpdateToMatchExtantCasing(string pathInGitRepo, IDictionary<string, GitObject> initialTree)
        {
            if (initialTree.ContainsKey(pathInGitRepo))
                return initialTree[pathInGitRepo].Path;

            var fullPath = pathInGitRepo;
            var splitResult = SplitDirnameFilename.Match(pathInGitRepo);
            if (splitResult.Success)
            {

                var dirName = splitResult.Groups["dir"].Value;
                var fileName = splitResult.Groups["file"].Value;
                fullPath = UpdateToMatchExtantCasing(dirName, initialTree) + "/" + fileName;
            }
            initialTree[fullPath] = new GitObject { Path = fullPath };
            return fullPath;
        }
Example #7
0
        private string UpdateToMatchExtantCasing_NEW(string pathInGitRepo, IDictionary<string, GitObject> initialTree)
        {
            if (initialTree.ContainsKey(pathInGitRepo))
                return initialTree[pathInGitRepo].Path;

            var fullPath = pathInGitRepo;
            var pathWithDirMatch = pathWithDirRegex.Match(pathInGitRepo);
            if (pathWithDirMatch.Success)
            {

                var dirName = pathWithDirMatch.Groups["dir"].Value;
                var fileName = pathWithDirMatch.Groups["file"].Value;
                fullPath = UpdateToMatchExtantCasing_NEW(dirName, initialTree) + "/" + fileName;
            }
            initialTree[fullPath] = new GitObject {Path = fullPath};
            return fullPath;
        }