|
1 | 1 | // Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
|
2 | 2 |
|
3 | 3 | #if UNITY_EDITOR
|
4 |
| -using System; |
5 | 4 | using System.Collections.Generic;
|
6 | 5 | using System.Diagnostics;
|
7 |
| -using System.Linq; |
8 | 6 | using Debug = UnityEngine.Debug;
|
9 | 7 |
|
10 | 8 | namespace CandyCoded.GitStatus
|
@@ -77,37 +75,55 @@ public static void CheckoutBranch(string branch)
|
77 | 75 |
|
78 | 76 | }
|
79 | 77 |
|
80 |
| - public static string[] AllChanges() |
| 78 | + public static string[] ChangedFiles() |
81 | 79 | {
|
82 | 80 |
|
83 | 81 | var process = Process.Start(new ProcessStartInfo
|
84 | 82 | {
|
85 | 83 | FileName = GitPath,
|
86 |
| - Arguments = "status --short --untracked-files --porcelain", |
| 84 | + Arguments = "status --short --untracked-files=no --porcelain", |
87 | 85 | UseShellExecute = false,
|
88 | 86 | RedirectStandardOutput = true,
|
89 | 87 | RedirectStandardError = true,
|
90 | 88 | CreateNoWindow = true
|
91 | 89 | });
|
92 | 90 |
|
93 |
| - return process?.StandardOutput |
94 |
| - .ReadToEnd() |
95 |
| - .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) |
96 |
| - .ToArray(); |
| 91 | + var changes = new List<string>(); |
97 | 92 |
|
98 |
| - } |
| 93 | + while (process?.StandardOutput.ReadLine() is string line) |
| 94 | + { |
99 | 95 |
|
100 |
| - public static string[] ChangedFiles() |
101 |
| - { |
| 96 | + changes.Add(line.Trim().TrimStart('M', ' ')); |
102 | 97 |
|
103 |
| - return AllChanges().Except(UntrackedFiles()).ToArray(); |
| 98 | + } |
| 99 | + |
| 100 | + return changes.ToArray(); |
104 | 101 |
|
105 | 102 | }
|
106 | 103 |
|
107 | 104 | public static string[] UntrackedFiles()
|
108 | 105 | {
|
109 | 106 |
|
110 |
| - return AllChanges().Where(file => file.StartsWith("??")).ToArray(); |
| 107 | + var process = Process.Start(new ProcessStartInfo |
| 108 | + { |
| 109 | + FileName = GitPath, |
| 110 | + Arguments = "ls-files --others --exclude-standard", |
| 111 | + UseShellExecute = false, |
| 112 | + RedirectStandardOutput = true, |
| 113 | + RedirectStandardError = true, |
| 114 | + CreateNoWindow = true |
| 115 | + }); |
| 116 | + |
| 117 | + var changes = new List<string>(); |
| 118 | + |
| 119 | + while (process?.StandardOutput.ReadLine() is string line) |
| 120 | + { |
| 121 | + |
| 122 | + changes.Add(line.Trim()); |
| 123 | + |
| 124 | + } |
| 125 | + |
| 126 | + return changes.ToArray(); |
111 | 127 |
|
112 | 128 | }
|
113 | 129 |
|
|
0 commit comments