Пример #1
0
        public void ShouldReturnUnreachableCommitHashesAfterRewind()
        {
            using (var tempFolder = new TemporaryFolder())
            {
                var tempRepository = new TemporaryRepository(tempFolder);
                var executor       = new GitCommandExecutor(tempFolder.Path);
                var log            = new LogRetriever(executor);

                tempRepository.RunCommand("init");
                tempRepository.TouchFileAndCommit();
                var firstCommitHash = log.GetRecentCommits(1).Single().Hash;
                tempRepository.TouchFileAndCommit();
                var secondCommitHash = log.GetRecentCommits(1).Single().Hash;
                tempRepository.RunCommand("reset --hard " + firstCommitHash);

                var orphanedHashes = log.GetRecentUnreachableCommitHashes();
                CollectionAssert.AreEqual(new[] { secondCommitHash }, orphanedHashes);
            }
        }
Пример #2
0
        public void ShouldLimitNumberOfUnreachableCommitHashesRetrieved()
        {
            using (var tempFolder = new TemporaryFolder())
            {
                var tempRepository = new TemporaryRepository(tempFolder);
                var executor       = new GitCommandExecutor(tempFolder.Path);
                var log            = new LogRetriever(executor);

                tempRepository.RunCommand("init");
                tempRepository.TouchFileAndCommit();
                var firstCommitHash = log.GetRecentCommits(1).Single().Hash;

                for (var i = 0; i < 20; i++)
                {
                    tempRepository.TouchFileAndCommit();
                }

                tempRepository.RunCommand("reset --hard " + firstCommitHash);

                var orphanedHashes = log.GetRecentUnreachableCommitHashes(10);
                Assert.AreEqual(10, orphanedHashes.Count());
            }
        }