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; diff --git a/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs b/src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs index 4ad7f6560..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; @@ -143,7 +144,6 @@ public override void LineReceived(string line) } summary = line; - descriptionLines.Add(line); phase++; // there's no description so skip it if (oneliner) @@ -313,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) { @@ -347,4 +348,4 @@ private enum ProcessingPhase Files = 10, } } -} \ No newline at end of file +} 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)); 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) { 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..347ea565b 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,94 @@ 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); + } + + [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 + { + 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); @@ -77,4 +165,4 @@ private void AssertProcessOutput(IEnumerable lines, GitLogEntry[] expect results.AssertEqual(expected); } } -} \ No newline at end of file +}