@@ -37,19 +37,6 @@ public enum EditorType
37
37
public bool RaiseError { get ; set ; } = true ;
38
38
public Models . ICommandLog Log { get ; set ; } = null ;
39
39
40
- public void Exec ( )
41
- {
42
- try
43
- {
44
- var start = CreateGitStartInfo ( false ) ;
45
- Process . Start ( start ) ;
46
- }
47
- catch ( Exception ex )
48
- {
49
- App . RaiseException ( Context , ex . Message ) ;
50
- }
51
- }
52
-
53
40
public async Task < bool > ExecAsync ( )
54
41
{
55
42
Log ? . AppendLine ( $ "$ git { Args } \n ") ;
@@ -127,6 +114,28 @@ public async Task<bool> ExecAsync()
127
114
return true ;
128
115
}
129
116
117
+ protected Result ReadToEnd ( )
118
+ {
119
+ using var proc = new Process ( ) { StartInfo = CreateGitStartInfo ( true ) } ;
120
+
121
+ try
122
+ {
123
+ proc . Start ( ) ;
124
+ }
125
+ catch ( Exception e )
126
+ {
127
+ return Result . Failed ( e . Message ) ;
128
+ }
129
+
130
+ var rs = new Result ( ) { IsSuccess = true } ;
131
+ rs . StdOut = proc . StandardOutput . ReadToEnd ( ) ;
132
+ rs . StdErr = proc . StandardError . ReadToEnd ( ) ;
133
+ proc . WaitForExit ( ) ;
134
+
135
+ rs . IsSuccess = proc . ExitCode == 0 ;
136
+ return rs ;
137
+ }
138
+
130
139
protected async Task < Result > ReadToEndAsync ( )
131
140
{
132
141
using var proc = new Process ( ) { StartInfo = CreateGitStartInfo ( true ) } ;
@@ -149,7 +158,7 @@ protected async Task<Result> ReadToEndAsync()
149
158
return rs ;
150
159
}
151
160
152
- private ProcessStartInfo CreateGitStartInfo ( bool redirect )
161
+ protected ProcessStartInfo CreateGitStartInfo ( bool redirect )
153
162
{
154
163
var start = new ProcessStartInfo ( ) ;
155
164
start . FileName = Native . OS . GitExecutable ;
@@ -167,8 +176,10 @@ private ProcessStartInfo CreateGitStartInfo(bool redirect)
167
176
// Force using this app as SSH askpass program
168
177
var selfExecFile = Process . GetCurrentProcess ( ) . MainModule ! . FileName ;
169
178
start . Environment . Add ( "SSH_ASKPASS" , selfExecFile ) ; // Can not use parameter here, because it invoked by SSH with `exec`
170
- start . Environment . Add ( "SSH_ASKPASS_REQUIRE" , "force " ) ;
179
+ start . Environment . Add ( "SSH_ASKPASS_REQUIRE" , "prefer " ) ;
171
180
start . Environment . Add ( "SOURCEGIT_LAUNCH_AS_ASKPASS" , "TRUE" ) ;
181
+ if ( ! OperatingSystem . IsLinux ( ) )
182
+ start . Environment . Add ( "DISPLAY" , "required" ) ;
172
183
173
184
// If an SSH private key was provided, sets the environment.
174
185
if ( ! start . Environment . ContainsKey ( "GIT_SSH_COMMAND" ) && ! string . IsNullOrEmpty ( SSHKey ) )
0 commit comments