void RefreshGraph(LogRetriever logRetriever) { var commits = logRetriever.GetRecentCommits().ToArray(); var activeRefName = logRetriever.GetActiveReferenceName(); var reachableCommitHashes = commits.Select(c => c.Hash).ToArray(); var unreachableHashes = logRetriever.GetRecentUnreachableCommitHashes(); var unreachableCommits = logRetriever .GetSpecificCommits(unreachableHashes) .Where(c => !reachableCommitHashes.Contains(c.Hash)) .ToArray(); _graph = GenerateGraphFromCommits(commits, activeRefName, unreachableCommits); OnPropertyChanged("Graph"); }
void RefreshGraph(LogRetriever logRetriever) { var commits = logRetriever.GetRecentCommits(NumOfCommitsToShow).ToArray(); var activeRefName = logRetriever.GetActiveReferenceName(); var reachableCommitHashes = commits.Select(c => c.Hash).ToArray(); var unreachableHashes = logRetriever.GetRecentUnreachableCommitHashes(); IEnumerable <Commit> unreachableCommits = null; if (VisualizeUnreachable) { unreachableCommits = logRetriever .GetSpecificCommits(unreachableHashes) .Where(c => !reachableCommitHashes.Contains(c.Hash)) .ToArray(); } Graph = GenerateGraphFromCommits(commits, activeRefName, unreachableCommits); }
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()); } }
void RefreshGraph(LogRetriever logRetriever) { var commits = logRetriever.GetRecentCommits().ToArray(); var activeRefName = logRetriever.GetActiveReferenceName(); var reachableCommitHashes = commits.Select(c => c.Hash).ToArray(); var unreachableHashes = logRetriever.GetRecentUnreachableCommitHashes(); var unreachableCommits = logRetriever .GetSpecificCommits(unreachableHashes) .Where(c => !reachableCommitHashes.Contains(c.Hash)) .ToArray(); _graph = GenerateGraphFromCommits(commits, activeRefName, unreachableCommits); OnPropertyChanged("Graph"); }
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); } }