Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
def test_zsplit(bs, expected):
    assert zsplit(bs) == expected