@@ -18,7 +18,7 @@ public static class Git
18
18
public static string GitPath => "/usr/local/bin/git" ;
19
19
#endif
20
20
21
- public static Task < Process > GenerateProcess ( string path , string arguments )
21
+ private static Task < Process > GenerateProcess ( string path , string arguments )
22
22
{
23
23
24
24
return Task . Run ( ( ) => Process . Start ( new ProcessStartInfo
@@ -60,13 +60,6 @@ public static async Task<string[]> Branches()
60
60
61
61
}
62
62
63
- public static void CheckoutBranch ( string branch )
64
- {
65
-
66
- GenerateProcess ( GitPath , $ "checkout { branch } ") ;
67
-
68
- }
69
-
70
63
public static async Task < string [ ] > ChangedFiles ( )
71
64
{
72
65
@@ -85,36 +78,43 @@ public static async Task<string[]> ChangedFiles()
85
78
86
79
}
87
80
88
- public static async Task < string [ ] > UntrackedFiles ( )
81
+ public static void CheckoutBranch ( string branch )
89
82
{
90
83
91
- var process = await GenerateProcess ( GitPath , "ls-files --others --exclude-standard ") ;
84
+ GenerateProcess ( GitPath , $ "checkout { branch } ") ;
92
85
93
- var changes = new List < string > ( ) ;
86
+ }
94
87
95
- while ( process ? . StandardOutput . ReadLine ( ) is string line )
88
+ public static async Task DiscardChanges ( string path )
89
+ {
90
+
91
+ var process = await GenerateProcess ( GitPath , $@ "checkout ""{ path } """);
92
+
93
+ if (process?.StandardError.ReadLine() is string line && line.StartsWith(" error: pathspec") )
96
94
{
97
95
98
- changes . Add ( line . Trim ( ) ) ;
96
+ Debug . LogError ( "File not tracked by git." ) ;
99
97
100
98
}
101
99
102
- return changes . ToArray ( ) ;
103
-
104
100
}
105
101
106
- public static async Task DiscardChanges ( string path )
102
+ public static async Task < string [ ] > UntrackedFiles ( )
107
103
{
108
104
109
- var process = await GenerateProcess ( GitPath , $@ "checkout "" { path } "" ");
105
+ var process = await GenerateProcess ( GitPath , "ls-files --others --exclude-standard ") ;
110
106
111
- if (process?.StandardError.ReadLine() is string line && line.StartsWith(" error: pathspec") )
107
+ var changes = new List < string > ( ) ;
108
+
109
+ while ( process ? . StandardOutput . ReadLine ( ) is string line )
112
110
{
113
111
114
- Debug . LogError ( "File not tracked by git." ) ;
112
+ changes . Add ( line . Trim ( ) ) ;
115
113
116
114
}
117
115
116
+ return changes . ToArray ( ) ;
117
+
118
118
}
119
119
120
120
}
0 commit comments