def ls_files(config, repo): path = os.path.join(config.output_dir, repo) ret = subprocess.run( ('git', '-C', path, 'ls-files', '-z'), stdout=subprocess.PIPE, check=True, ) return path, zsplit(ret.stdout)
def ls_files(config: Config, repo: str) -> Tuple[str, List[bytes]]: path = os.path.join(config.output_dir, repo) ret = subprocess.run( ('git', '-C', path, 'ls-files', '-z'), stdout=subprocess.PIPE, check=True, ) return path, zsplit(ret.stdout)
def apply_fix( *, ls_files_cmd: Sequence[str], sed_cmd: Sequence[str], ) -> None: filenames_b = zsplit(subprocess.check_output(ls_files_cmd)) filenames = [f.decode() for f in filenames_b] filenames = [f for f in filenames if tags_from_path(f) & {'file', 'text'}] autofix_lib.run(*sed_cmd, *filenames)
def apply_fix() -> None: # Fix CI config path = Path("LICENSE.txt") if path.exists(): newpath = path.rename("LICENSE") autofix_lib.run("git", "rm", str(path)) autofix_lib.run("git", "add", str(newpath)) filenames_b = zsplit(subprocess.check_output(["git", "ls-files", "-z"])) filenames = [f.decode() for f in filenames_b] autofix_lib.run("sed", "-i", "s/LICENSE.txt/LICENSE/g", *filenames)
def apply_fix(*, ls_files_cmd, sed_cmd): filenames = zsplit(subprocess.check_output(ls_files_cmd)) filenames = [f.decode() for f in filenames] autofix_lib.run(*sed_cmd, *filenames)
def test_zsplit(bs, expected): assert zsplit(bs) == expected