Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Removing newline processed from LogEntryOutputProcessor #1003

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -346,4 +348,4 @@ private enum ProcessingPhase
Files = 10,
}
}
}
}
49 changes: 47 additions & 2 deletions src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GitStatusEntry>
{
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<GitStatusEntry>
Expand Down Expand Up @@ -120,4 +165,4 @@ private void AssertProcessOutput(IEnumerable<string> lines, GitLogEntry[] expect
results.AssertEqual(expected);
}
}
}
}