Beispiel #1
0
        private void Prepare(int comparisons, out string[] content1, out string[] content2)
        {
            string             repoDir            = TestUtils.ExtractZippedRepo("vcpkg.git");
            RepositoryAnalyzer repositoryAnalyzer = new RepositoryAnalyzer(repoDir);
            RepositoryReader   repositoryReader   = new RepositoryReader(repoDir);

            content1 = new string[comparisons];
            content2 = new string[comparisons];
            int i = 0;

            foreach (Commit commit in repositoryAnalyzer.GetCommits().Where(x => x.Parents.Any()))
            {
                Dictionary <string, PathHashMode> current = repositoryAnalyzer.GetPathAndHashForFiles(commit.Hash).ToDictionary(x => x.Path);
                Dictionary <string, PathHashMode> parent  = repositoryAnalyzer.GetPathAndHashForFiles(commit.Parents[0]).ToDictionary(x => x.Path);
                foreach ((string hash1, string hash2) in current.Keys.Intersect(parent.Keys).Select(x => (current[x].Hash, parent[x].Hash)))
                {
                    if (hash1 != hash2)
                    {
                        content1[i] = repositoryReader.ReadBlob(hash1);
                        content2[i] = repositoryReader.ReadBlob(hash2);
                        i++;
                    }
                    if (i == comparisons)
                    {
                        break;
                    }
                }
                if (i == comparisons)
                {
                    break;
                }
            }
        }
        public void Test02ReadLooseBlob()
        {
            string           repoDir = TestUtils.ExtractZippedRepo("TestRepo02");
            RepositoryReader reader  = new RepositoryReader(repoDir);
            string           res     = reader.ReadBlob("31d6d2184fe8deab8e52bd9581d67f35d4ecd5ca");

            Assert.AreEqual("abc xyz", res);
        }
        public void Test01ReadLooseBlob()
        {
            string           repoDir = TestUtils.ExtractZippedRepo("TestRepo01");
            RepositoryReader reader  = new RepositoryReader(repoDir);
            string           res     = reader.ReadBlob("d670460b4b4aece5915caf5c68d12f560a9fe3e4");

            Assert.AreEqual("test content\n", res);
        }