From 1e02b3bfcf41d825141feb9e24bec2fee522e34b Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 21 Dec 2018 09:28:44 +0000 Subject: [PATCH 1/7] The description should not contain the summary --- src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs b/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs index 4ad7f6560..6321332a7 100644 --- a/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs +++ b/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs @@ -143,7 +143,6 @@ public override void LineReceived(string line) } summary = line; - descriptionLines.Add(line); phase++; // there's no description so skip it if (oneliner) From a116d5fefa96a166b33e7f41a2523947cdf4e69e Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 21 Dec 2018 09:29:24 +0000 Subject: [PATCH 2/7] Make it possible to switch repositories easily --- src/GitHub.Api/Platform/DefaultEnvironment.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitHub.Api/Platform/DefaultEnvironment.cs b/src/GitHub.Api/Platform/DefaultEnvironment.cs index 2eed349ba..2caede5a5 100644 --- a/src/GitHub.Api/Platform/DefaultEnvironment.cs +++ b/src/GitHub.Api/Platform/DefaultEnvironment.cs @@ -83,7 +83,7 @@ public void InitializeRepository(NPath? repositoryPath = null) Guard.NotNull(this, FileSystem, nameof(FileSystem)); NPath expectedRepositoryPath; - if (!RepositoryPath.IsInitialized) + if (!RepositoryPath.IsInitialized || (repositoryPath != null && RepositoryPath != repositoryPath.Value)) { Guard.NotNull(this, UnityProjectPath, nameof(UnityProjectPath)); From 4cd00a66e8374cdd969adef737e4ba94830a41dd Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 21 Dec 2018 09:29:38 +0000 Subject: [PATCH 3/7] Make useful api public --- src/GitHub.Api/Tasks/ActionTask.cs | 20 ++++++++++---------- src/GitHub.Api/Tasks/TaskBase.cs | 8 ++++---- src/GitHub.Api/Tasks/TaskExtensions.cs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/GitHub.Api/Tasks/ActionTask.cs b/src/GitHub.Api/Tasks/ActionTask.cs index 73692baea..d42a9d1ff 100644 --- a/src/GitHub.Api/Tasks/ActionTask.cs +++ b/src/GitHub.Api/Tasks/ActionTask.cs @@ -7,7 +7,7 @@ namespace GitHub.Unity { - class TaskQueue : TPLTask + public class TaskQueue : TPLTask { private TaskCompletionSource aggregateTask = new TaskCompletionSource(); private readonly List queuedTasks = new List(); @@ -85,7 +85,7 @@ private void TaskFinished(bool success, Exception ex) } } - class TaskQueue : TPLTask> + public class TaskQueue : TPLTask> { private TaskCompletionSource> aggregateTask = new TaskCompletionSource>(); private readonly List> queuedTasks = new List>(); @@ -190,7 +190,7 @@ private void TaskFinished(TTaskResult result, bool success, Exception ex) } } - class TPLTask : TaskBase + public class TPLTask : TaskBase { private Task task; @@ -235,7 +235,7 @@ protected override void Run(bool success) } } - class TPLTask : TaskBase + public class TPLTask : TaskBase { private Task task; @@ -280,7 +280,7 @@ protected override T RunWithReturn(bool success) } } - class ActionTask : TaskBase + public class ActionTask : TaskBase { protected Action Callback { get; } protected Action CallbackWithException { get; } @@ -329,7 +329,7 @@ protected override void Run(bool success) } } - class ActionTask : TaskBase + public class ActionTask : TaskBase { private readonly Func getPreviousResult; @@ -415,7 +415,7 @@ protected virtual void Run(bool success, T previousResult) public T PreviousResult { get; set; } = default(T); } - class FuncTask : TaskBase + public class FuncTask : TaskBase { protected Func Callback { get; } protected Func CallbackWithException { get; } @@ -468,7 +468,7 @@ protected override T RunWithReturn(bool success) } } - class FuncTask : TaskBase + public class FuncTask : TaskBase { protected Func Callback { get; } protected Func CallbackWithException { get; } @@ -513,7 +513,7 @@ protected override TResult RunWithData(bool success, T previousResult) } } - class FuncListTask : DataTaskBase> + public class FuncListTask : DataTaskBase> { protected Func> Callback { get; } protected Func, List> CallbackWithSelf { get; } @@ -573,7 +573,7 @@ protected override List RunWithReturn(bool success) } } - class FuncListTask : DataTaskBase> + public class FuncListTask : DataTaskBase> { protected Func> Callback { get; } protected Func> CallbackWithException { get; } diff --git a/src/GitHub.Api/Tasks/TaskBase.cs b/src/GitHub.Api/Tasks/TaskBase.cs index 99d169152..768c011d5 100644 --- a/src/GitHub.Api/Tasks/TaskBase.cs +++ b/src/GitHub.Api/Tasks/TaskBase.cs @@ -547,7 +547,7 @@ public override string ToString() public virtual string Message { get; set; } } - abstract class TaskBase : TaskBase, ITask + public abstract class TaskBase : TaskBase, ITask { private event Action finallyHandler; @@ -723,7 +723,7 @@ protected override void CallFinallyHandler() public TResult Result { get { return result; } } } - abstract class TaskBase : TaskBase + public abstract class TaskBase : TaskBase { private readonly Func getPreviousResult; @@ -770,7 +770,7 @@ protected virtual TResult RunWithData(bool success, T previousResult) public T PreviousResult { get; set; } = default(T); } - abstract class DataTaskBase : TaskBase, ITask + public abstract class DataTaskBase : TaskBase, ITask { public DataTaskBase(CancellationToken token) : base(token) @@ -783,7 +783,7 @@ protected void RaiseOnData(TData data) } } - abstract class DataTaskBase : TaskBase, ITask + public abstract class DataTaskBase : TaskBase, ITask { public DataTaskBase(CancellationToken token) : base(token) diff --git a/src/GitHub.Api/Tasks/TaskExtensions.cs b/src/GitHub.Api/Tasks/TaskExtensions.cs index 57e17170d..fa634aaa9 100644 --- a/src/GitHub.Api/Tasks/TaskExtensions.cs +++ b/src/GitHub.Api/Tasks/TaskExtensions.cs @@ -4,7 +4,7 @@ namespace GitHub.Unity { - static class TaskExtensions + public static class TaskExtensions { public static async Task StartAwait(this ITask source, Action handler = null) { From a992d2cb9c66a28e1a789184cd0f657cc7e2d57a Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 21 Dec 2018 10:07:24 +0000 Subject: [PATCH 4/7] Fix some tests --- .../Process/ProcessManagerIntegrationTests.cs | 11 +++-- .../IO/LogEntryOutputProcessorTests.cs | 47 ++++++++++++++++++- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs b/src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs index 9ab837f95..342d35088 100644 --- a/src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs +++ b/src/tests/IntegrationTests/Process/ProcessManagerIntegrationTests.cs @@ -46,8 +46,9 @@ public async Task LogEntriesTest() new GitLogEntry("018997938335742f8be694240a7c2b352ec0835f", "Author Person", "author@example.com", "Author Person", "author@example.com", - "Moving project files where they should be kept", - "Moving project files where they should be kept", firstCommitTime, + "Moving project files where they should be kept", + "", + firstCommitTime, firstCommitTime, new List { new GitStatusEntry("Assets/TestDocument.txt".ToNPath(), @@ -59,7 +60,8 @@ public async Task LogEntriesTest() "Author Person", "author@example.com", "Author Person", "author@example.com", "Initial Commit", - "Initial Commit", secondCommitTime, + "", + secondCommitTime, secondCommitTime, new List { new GitStatusEntry("TestDocument.txt".ToNPath(), @@ -87,7 +89,8 @@ public async Task RussianLogEntriesTest() "Author Person", "author@example.com", "Author Person", "author@example.com", "Я люблю github", - "Я люблю github", commitTime, + "", + commitTime, commitTime, new List { new GitStatusEntry(@"Assets\A new file.txt".ToNPath(), diff --git a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs index 5c0bc3a5c..a24046922 100644 --- a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs +++ b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs @@ -46,9 +46,9 @@ public void ShouldParseSingleCommit() { new GitLogEntry("1cd4b9154a88bc8c7b09cb8cacc79bf1d5bde8cf", "Author Person", "author@example.com", - "Author Person", "author@example.com", - "Rename RepositoryModelBase to RepositoryModel", + "Author Person", "author@example.com", "Rename RepositoryModelBase to RepositoryModel", + "", commitTime, commitTime, new List { @@ -61,6 +61,49 @@ public void ShouldParseSingleCommit() AssertProcessOutput(output, expected); } + [Test] + public void ShouldParseSummaryAndDescription() + { + 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", + "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); + } + private void AssertProcessOutput(IEnumerable lines, GitLogEntry[] expected) { var gitObjectFactory = SubstituteFactory.CreateGitObjectFactory(TestRootPath); From b4f84f76b368964a4b991b61f2a9a4de1ed825e1 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Fri, 21 Dec 2018 12:42:07 +0000 Subject: [PATCH 5/7] New lines are a thing here --- src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs index a24046922..ccd195685 100644 --- a/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs +++ b/src/tests/UnitTests/IO/LogEntryOutputProcessorTests.cs @@ -90,7 +90,7 @@ public void ShouldParseSummaryAndDescription() "Author Person", "author@example.com", "Author Person", "author@example.com", "Rename RepositoryModelBase to RepositoryModel", - "This is a line on the description", + Environment.NewLine + "This is a line on the description", commitTime, commitTime, new List From d3349ce4ae4e81923c1edd143776792746bb3cb0 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Wed, 9 Jan 2019 18:28:46 +0100 Subject: [PATCH 6/7] This is handy to have --- src/GitHub.Api/Helpers/SimpleJson.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitHub.Api/Helpers/SimpleJson.cs b/src/GitHub.Api/Helpers/SimpleJson.cs index cdb9fb7d7..1ae5e3ba7 100644 --- a/src/GitHub.Api/Helpers/SimpleJson.cs +++ b/src/GitHub.Api/Helpers/SimpleJson.cs @@ -2214,7 +2214,7 @@ private static string ToJsonPropertyName(string propertyName) return propertyName.Substring(0, i).ToLowerInvariant() + propertyName.Substring(i); } - class JsonSerializationStrategy : PocoJsonSerializerStrategy + public class JsonSerializationStrategy : PocoJsonSerializerStrategy { private bool toLowerCase = false; private bool onlyPublic = true; From f89ac7fb2fe8ff58715eeacee11dbcbc0336ab17 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Wed, 23 Jan 2019 08:13:47 -0500 Subject: [PATCH 7/7] 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 +}