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

Commit 381ae22

Browse files
authored
Merge pull request #1003 from github-for-unity/fixes/api-newline
Removing newline processed from LogEntryOutputProcessor
2 parents d3349ce + f89ac7f commit 381ae22

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4+
using System.Linq;
45
using System.Text;
56
using System.Text.RegularExpressions;
67

@@ -312,7 +313,8 @@ private void ReturnGitLogEntry()
312313
{
313314
PopNewlines();
314315

315-
var description = string.Join(Environment.NewLine, descriptionLines.ToArray());
316+
var filteredDescriptionLines = (descriptionLines.Any() && string.IsNullOrEmpty(descriptionLines.First()) ? descriptionLines.Skip(1) : descriptionLines).ToArray();
317+
var description = string.Join(Environment.NewLine, filteredDescriptionLines);
316318

317319
if (time.HasValue)
318320
{
@@ -346,4 +348,4 @@ private enum ProcessingPhase
346348
Files = 10,
347349
}
348350
}
349-
}
351+
}

src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,52 @@ public void ShouldParseSummaryAndDescription()
9090
"Author Person", "author@example.com",
9191
"Author Person", "author@example.com",
9292
"Rename RepositoryModelBase to RepositoryModel",
93-
Environment.NewLine + "This is a line on the description",
93+
"This is a line on the description",
94+
commitTime,
95+
commitTime,
96+
new List<GitStatusEntry>
97+
{
98+
new GitStatusEntry("src/GitHub.App/Models/RemoteRepositoryModel.cs",
99+
TestRootPath + @"\src/GitHub.App/Models/RemoteRepositoryModel.cs", null,
100+
GitFileStatus.Modified),
101+
})
102+
};
103+
104+
AssertProcessOutput(output, expected);
105+
}
106+
107+
[Test]
108+
public void ShouldParseSummaryAndDescriptionWithExtraNewLines()
109+
{
110+
var output = new[]
111+
{
112+
"1cd4b9154a88bc8c7b09cb8cacc79bf1d5bde8cf",
113+
"865b8d9d6e5e3bd6d7a4dc9c9f3588192314942c",
114+
"Author Person",
115+
"author@example.com",
116+
"2017-01-06T15:36:57+01:00",
117+
"Author Person",
118+
"author@example.com",
119+
"2017-01-06T15:36:57+01:00",
120+
"Rename RepositoryModelBase to RepositoryModel",
121+
"",
122+
"",
123+
"",
124+
"This is a line on the description",
125+
"---GHUBODYEND---",
126+
"M src/GitHub.App/Models/RemoteRepositoryModel.cs",
127+
null,
128+
};
129+
130+
var commitTime = new DateTimeOffset(2017, 1, 6, 15, 36, 57, TimeSpan.FromHours(1));
131+
132+
var expected = new[]
133+
{
134+
new GitLogEntry("1cd4b9154a88bc8c7b09cb8cacc79bf1d5bde8cf",
135+
"Author Person", "author@example.com",
136+
"Author Person", "author@example.com",
137+
"Rename RepositoryModelBase to RepositoryModel",
138+
Environment.NewLine + Environment.NewLine + "This is a line on the description",
94139
commitTime,
95140
commitTime,
96141
new List<GitStatusEntry>
@@ -120,4 +165,4 @@ private void AssertProcessOutput(IEnumerable<string> lines, GitLogEntry[] expect
120165
results.AssertEqual(expected);
121166
}
122167
}
123-
}
168+
}

0 commit comments

Comments
 (0)