From f89ac7fb2fe8ff58715eeacee11dbcbc0336ab17 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Wed, 23 Jan 2019 08:13:47 -0500 Subject: [PATCH] Removing newline processed from LogEntryOutputProcessor --- .../LogEntryOutputProcessor.cs | 6 ++- .../IO/LogEntryOutputProcessorTests.cs | 49 ++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs b/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs index 6321332a7..f0d011039 100644 --- a/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs +++ b/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -312,7 +313,8 @@ private void ReturnGitLogEntry() { PopNewlines(); - var description = string.Join(Environment.NewLine, descriptionLines.ToArray()); + var filteredDescriptionLines = (descriptionLines.Any() && string.IsNullOrEmpty(descriptionLines.First()) ? descriptionLines.Skip(1) : descriptionLines).ToArray(); + var description = string.Join(Environment.NewLine, filteredDescriptionLines); if (time.HasValue) { @@ -346,4 +348,4 @@ private enum ProcessingPhase Files = 10, } } -} \ No newline at end of file +} diff --git a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs index ccd195685..347ea565b 100644 --- a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs +++ b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs @@ -90,7 +90,52 @@ public void ShouldParseSummaryAndDescription() "Author Person", "author@example.com", "Author Person", "author@example.com", "Rename RepositoryModelBase to RepositoryModel", - Environment.NewLine + "This is a line on the description", + "This is a line on the description", + commitTime, + commitTime, + new List + { + new GitStatusEntry("src/GitHub.App/Models/RemoteRepositoryModel.cs", + TestRootPath + @"\src/GitHub.App/Models/RemoteRepositoryModel.cs", null, + GitFileStatus.Modified), + }) + }; + + AssertProcessOutput(output, expected); + } + + [Test] + public void ShouldParseSummaryAndDescriptionWithExtraNewLines() + { + var output = new[] + { + "1cd4b9154a88bc8c7b09cb8cacc79bf1d5bde8cf", + "865b8d9d6e5e3bd6d7a4dc9c9f3588192314942c", + "Author Person", + "author@example.com", + "2017-01-06T15:36:57+01:00", + "Author Person", + "author@example.com", + "2017-01-06T15:36:57+01:00", + "Rename RepositoryModelBase to RepositoryModel", + "", + "", + "", + "This is a line on the description", + "---GHUBODYEND---", + "M src/GitHub.App/Models/RemoteRepositoryModel.cs", + null, + }; + + var commitTime = new DateTimeOffset(2017, 1, 6, 15, 36, 57, TimeSpan.FromHours(1)); + + var expected = new[] + { + new GitLogEntry("1cd4b9154a88bc8c7b09cb8cacc79bf1d5bde8cf", + "Author Person", "author@example.com", + "Author Person", "author@example.com", + "Rename RepositoryModelBase to RepositoryModel", + Environment.NewLine + Environment.NewLine + "This is a line on the description", commitTime, commitTime, new List @@ -120,4 +165,4 @@ private void AssertProcessOutput(IEnumerable lines, GitLogEntry[] expect results.AssertEqual(expected); } } -} \ No newline at end of file +}