@@ -364,6 +364,7 @@ class RemoteProgress(object):
364
364
'_seen_ops' ,
365
365
'error_lines' , # Lines that started with 'error:' or 'fatal:'.
366
366
'other_lines' ) # Lines not denoting progress (i.e.g. push-infos).
367
+ re_ansi_escape = re .compile (r'\x1B[@-_][0-?]*[ -/]*[@-~]' )
367
368
re_op_absolute = re .compile (r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)" )
368
369
re_op_relative = re .compile (r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)" )
369
370
@@ -392,17 +393,24 @@ def _parse_progress_line(self, line):
392
393
393
394
# find escape characters and cut them away - regex will not work with
394
395
# them as they are non-ascii. As git might expect a tty, it will send them
395
- last_valid_index = None
396
- for i , c in enumerate (reversed (line )):
396
+ log .warning ("raw line: " + str (list (line )))
397
+ sline = line
398
+ last_valid_index = None
399
+ for i , c in enumerate (reversed (sline )):
397
400
if ord (c ) < 32 :
398
401
# its a slice index
399
402
last_valid_index = - i - 1
400
403
# END character was non-ascii
401
- # END for each character in line
404
+ # END for each character in sline
402
405
if last_valid_index is not None :
403
- line = line [:last_valid_index ]
406
+ sline = sline [:last_valid_index ]
404
407
# END cut away invalid part
405
- line = line .rstrip ()
408
+ sline = sline .rstrip ()
409
+ log .warning ("old stripping logic: " + str (sline ))
410
+
411
+ line = self .re_ansi_escape .sub ('' , line )
412
+ line .strip ()
413
+ log .warning ("new stripping logic: " + str (line ))
406
414
407
415
cur_count , max_count = None , None
408
416
match = self .re_op_relative .match (line )
0 commit comments