File tree Expand file tree Collapse file tree 2 files changed +15
-17
lines changed
Expand file tree Collapse file tree 2 files changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -21,21 +21,7 @@ impl From<git2_hooks::HookResult> for HookResult {
2121 stdout,
2222 stderr,
2323 ..
24- } => {
25- let mut combined = format ! ( "{stdout}{stderr}" ) ;
26-
27- if cfg ! ( windows) {
28- const ANSI_CLEAR : & str = "\x1B [H\x1B [2J\x1B [3J" ;
29-
30- if let Some ( trimmed) =
31- combined. strip_suffix ( ANSI_CLEAR )
32- {
33- combined. truncate ( trimmed. len ( ) ) ;
34- }
35- }
36-
37- Self :: NotOk ( combined)
38- }
24+ } => Self :: NotOk ( format ! ( "{stdout}{stderr}" ) ) ,
3925 }
4026 }
4127}
Original file line number Diff line number Diff line change @@ -134,11 +134,23 @@ impl HookPaths {
134134 if output. status . success ( ) {
135135 Ok ( HookResult :: Ok { hook } )
136136 } else {
137- let stderr =
137+ let mut stderr =
138138 String :: from_utf8_lossy ( & output. stderr ) . to_string ( ) ;
139- let stdout =
139+ let mut stdout =
140140 String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ;
141141
142+ if cfg ! ( windows) {
143+ const ANSI_CLEAR : & str = "\x1B [H\x1B [2J\x1B [3J" ;
144+
145+ for text in [ & mut stderr, & mut stdout] {
146+ if let Some ( trimmed) =
147+ text. strip_suffix ( ANSI_CLEAR )
148+ {
149+ text. truncate ( trimmed. len ( ) ) ;
150+ }
151+ }
152+ }
153+
142154 Ok ( HookResult :: RunNotSuccessful {
143155 code : output. status . code ( ) ,
144156 stdout,
You can’t perform that action at this time.
0 commit comments