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

Commit 58d4552

Browse files
Merge pull request #698 from github-for-unity/fixes/changes-view-sort-order
Sorting GitStatus entries
2 parents 37adad3 + 8fd5932 commit 58d4552

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/GitHub.Api/Git/Tasks/GitStatusTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GitStatusTask : ProcessTask<GitStatus>
88

99
public GitStatusTask(IGitObjectFactory gitObjectFactory,
1010
CancellationToken token, IOutputProcessor<GitStatus> processor = null)
11-
: base(token, processor ?? new StatusOutputProcessor(gitObjectFactory))
11+
: base(token, processor ?? new GitStatusOutputProcessor(gitObjectFactory))
1212
{
1313
Name = TaskName;
1414
}

src/GitHub.Api/OutputProcessors/StatusOutputProcessor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
namespace GitHub.Unity
77
{
8-
class StatusOutputProcessor : BaseOutputProcessor<GitStatus>
8+
class GitStatusOutputProcessor : BaseOutputProcessor<GitStatus>
99
{
1010
private static readonly Regex branchTrackedAndDelta = new Regex(@"(.*)\.\.\.(.*)\s\[(.*)\]",
1111
RegexOptions.Compiled);
1212

1313
private readonly IGitObjectFactory gitObjectFactory;
1414
GitStatus gitStatus;
1515

16-
public StatusOutputProcessor(IGitObjectFactory gitObjectFactory)
16+
public GitStatusOutputProcessor(IGitObjectFactory gitObjectFactory)
1717
{
1818
Guard.ArgumentNotNull(gitObjectFactory, "gitObjectFactory");
1919
this.gitObjectFactory = gitObjectFactory;
@@ -190,6 +190,10 @@ private void ReturnStatus()
190190
if (gitStatus.Entries == null)
191191
return;
192192

193+
gitStatus.Entries = gitStatus.Entries
194+
.OrderBy(entry => entry.Path)
195+
.ToList();
196+
193197
RaiseOnEntry(gitStatus);
194198

195199
gitStatus = new GitStatus();

src/tests/IntegrationTests/ProcessManagerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static ITask<GitStatus> GetGitStatus(this IProcessManager processManager,
5050
NPath? gitPath = null)
5151
{
5252
var gitStatusEntryFactory = new GitObjectFactory(environment);
53-
var processor = new StatusOutputProcessor(gitStatusEntryFactory);
53+
var processor = new GitStatusOutputProcessor(gitStatusEntryFactory);
5454

5555
NPath path = gitPath ?? defaultGitPath;
5656

src/tests/UnitTests/IO/StatusOutputProcessorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void AssertProcessOutput(IEnumerable<string> lines, GitStatus expected)
250250
var gitObjectFactory = SubstituteFactory.CreateGitObjectFactory(TestRootPath);
251251

252252
GitStatus? result = null;
253-
var outputProcessor = new StatusOutputProcessor(gitObjectFactory);
253+
var outputProcessor = new GitStatusOutputProcessor(gitObjectFactory);
254254
outputProcessor.OnEntry += status => { result = status; };
255255

256256
foreach (var line in lines)

src/tests/UnitTests/ProcessManagerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static async Task<GitStatus> GetGitStatus(this ProcessManager processMana
5858
NPath? gitPath = null)
5959
{
6060
var gitStatusEntryFactory = new GitObjectFactory(environment);
61-
var processor = new StatusOutputProcessor(gitStatusEntryFactory);
61+
var processor = new GitStatusOutputProcessor(gitStatusEntryFactory);
6262

6363
NPath path = gitPath ?? defaultGitPath;
6464

0 commit comments

Comments
 (0)