File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,16 @@ def __str__(self) -> str:
499499 return ret
500500
501501
502+ def _redact_base_dir (output : str , base_dir : Path ) -> str :
503+ base_dir_re = (
504+ r"^(?P<header>[^:]*?)"
505+ f"(?:{ re .escape (str (base_dir .resolve ()))} "
506+ f"|{ re .escape (str (base_dir ))} )"
507+ r"(?:[^:]*?_(new|old)/)?(?P<trailer>[^:\s]*(:|$))"
508+ )
509+ return re .sub (base_dir_re , r"\g<header>...\g<trailer>" , output , flags = re .MULTILINE )
510+
511+
502512@dataclass (frozen = True )
503513class PrimerResult :
504514 project : Project
@@ -517,18 +527,8 @@ def _get_diff(self) -> str:
517527
518528 # Redact lines which contain essentially "{base_dir}.*" before a colon
519529 # Avoids noisy diffs when e.g. a type checker points to a stub definition
520- base_dir_re = (
521- r"^(?P<header>[^:]*?)"
522- f"(?:{ re .escape (str (ctx .get ().base_dir .resolve ()))} "
523- f"|{ re .escape (str (ctx .get ().base_dir ))} )"
524- r"[^:\s]*(?P<trailer>(:|$))"
525- )
526- old_output = re .sub (
527- base_dir_re , r"\g<header>...\g<trailer>" , old_output , flags = re .MULTILINE
528- )
529- new_output = re .sub (
530- base_dir_re , r"\g<header>...\g<trailer>" , new_output , flags = re .MULTILINE
531- )
530+ old_output = _redact_base_dir (old_output , ctx .get ().base_dir )
531+ new_output = _redact_base_dir (new_output , ctx .get ().base_dir )
532532
533533 old_lines = old_output .splitlines ()
534534 new_lines = new_output .splitlines ()
You can’t perform that action at this time.
0 commit comments