private static string generateDifferenceReport(string filePath, Repository repo, Commit commit, string baseRepositoryPath) { var sourceRepoOpts = configureTemporaryRepository(baseRepositoryPath, "source"); var targetRepoOpts = configureTemporaryRepository(baseRepositoryPath, "target"); using (var sourceRepo = new Repository(repo.Info.Path, sourceRepoOpts)) using (var targetRepo = new Repository(repo.Info.Path, targetRepoOpts)) { var parentCommit = commit.Parents.First(); var sourceFileContents = getFileBySha(sourceRepo, filePath, parentCommit.Sha); var targetFileContents = getFileBySha(targetRepo, filePath, commit.Sha); return(CodeUtils.DescribeDifferencesFromContents(sourceFileContents, targetFileContents, filePath)); } }
private static IEnumerable <string> generateDifferenceReports(IEnumerable <string> filePaths, Repository repo, Commit commit, string baseRepositoryPath) { var sourceRepoOpts = configureTemporaryRepository(baseRepositoryPath, "source"); var targetRepoOpts = configureTemporaryRepository(baseRepositoryPath, "target"); using (var sourceRepo = new Repository(repo.Info.Path, sourceRepoOpts)) using (var targetRepo = new Repository(repo.Info.Path, targetRepoOpts)) { var parentCommit = commit.Parents.First(); var sourceFileContents = getFilesBySha(sourceRepo, filePaths, parentCommit.Sha); var targetFileContents = getFilesBySha(targetRepo, filePaths, commit.Sha); foreach (var filePath in filePaths) { yield return(CodeUtils.DescribeDifferencesFromContents(sourceFileContents[filePath], targetFileContents[filePath], filePath)); } } }