3
3
#if UNITY_EDITOR
4
4
using System . Collections . Generic ;
5
5
using System . Diagnostics ;
6
+ using System . Threading . Tasks ;
6
7
using Debug = UnityEngine . Debug ;
7
8
8
9
namespace CandyCoded . GitStatus
@@ -17,34 +18,34 @@ public static class Git
17
18
public static string GitPath => "/usr/local/bin/git" ;
18
19
#endif
19
20
20
- public static Process GenerateProcess ( string path , string arguments )
21
+ public static Task < Process > GenerateProcess ( string path , string arguments )
21
22
{
22
23
23
- return Process . Start ( new ProcessStartInfo
24
+ return Task . Run ( ( ) => Process . Start ( new ProcessStartInfo
24
25
{
25
26
FileName = path ,
26
27
Arguments = arguments ,
27
28
UseShellExecute = false ,
28
29
RedirectStandardOutput = true ,
29
30
RedirectStandardError = true ,
30
31
CreateNoWindow = true
31
- } ) ;
32
+ } ) ) ;
32
33
33
34
}
34
35
35
- public static string Branch ( )
36
+ public static async Task < string > Branch ( )
36
37
{
37
38
38
- var process = GenerateProcess ( GitPath , "rev-parse --abbrev-ref HEAD" ) ;
39
+ var process = await GenerateProcess ( GitPath , "rev-parse --abbrev-ref HEAD" ) ;
39
40
40
41
return process ? . StandardOutput . ReadLine ( ) ;
41
42
42
43
}
43
44
44
- public static string [ ] Branches ( )
45
+ public static async Task < string [ ] > Branches ( )
45
46
{
46
47
47
- var process = GenerateProcess ( GitPath , "for-each-ref --format='%(refname:short)' refs/heads" ) ;
48
+ var process = await GenerateProcess ( GitPath , "for-each-ref --format='%(refname:short)' refs/heads" ) ;
48
49
49
50
var branches = new List < string > ( ) ;
50
51
@@ -66,10 +67,10 @@ public static void CheckoutBranch(string branch)
66
67
67
68
}
68
69
69
- public static string [ ] ChangedFiles ( )
70
+ public static async Task < string [ ] > ChangedFiles ( )
70
71
{
71
72
72
- var process = GenerateProcess ( GitPath , "status --short --untracked-files=no --porcelain" ) ;
73
+ var process = await GenerateProcess ( GitPath , "status --short --untracked-files=no --porcelain" ) ;
73
74
74
75
var changes = new List < string > ( ) ;
75
76
@@ -84,10 +85,10 @@ public static string[] ChangedFiles()
84
85
85
86
}
86
87
87
- public static string [ ] UntrackedFiles ( )
88
+ public static async Task < string [ ] > UntrackedFiles ( )
88
89
{
89
90
90
- var process = GenerateProcess ( GitPath , "ls-files --others --exclude-standard" ) ;
91
+ var process = await GenerateProcess ( GitPath , "ls-files --others --exclude-standard" ) ;
91
92
92
93
var changes = new List < string > ( ) ;
93
94
@@ -102,10 +103,10 @@ public static string[] UntrackedFiles()
102
103
103
104
}
104
105
105
- public static void DiscardChanges ( string path )
106
+ public static async Task DiscardChanges ( string path )
106
107
{
107
108
108
- var process = GenerateProcess ( GitPath , $@ "checkout ""{ path } """);
109
+ var process = await GenerateProcess ( GitPath , $@ "checkout ""{ path } """);
109
110
110
111
if (process?.StandardError.ReadLine() is string line && line.StartsWith(" error: pathspec") )
111
112
{
0 commit comments