MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / cd

Function cd

pre_commit/commands/hazmat.py:44–56  ·  view source on GitHub ↗
(subdir: str, cmd: tuple[str, ...])

Source from the content-addressed store, hash-verified

42
43
44def cd(subdir: str, cmd: tuple[str, ...]) -> int:
45 cmd, filenames = _cmd_filenames(cmd)
46
47 prefix = f'{subdir}/'
48 new_filenames = []
49 for filename in filenames:
50 if not filename.startswith(prefix):
51 raise SystemExit(f'unexpected file without {prefix=}: {filename}')
52 else:
53 new_filenames.append(filename.removeprefix(prefix))
54
55 cmd = normalize_cmd(cmd)
56 return subprocess.call((*cmd, *new_filenames), cwd=subdir)
57
58
59def ignore_exit_code(cmd: tuple[str, ...]) -> int:

Callers 1

implFunction · 0.85

Calls 2

normalize_cmdFunction · 0.90
_cmd_filenamesFunction · 0.85

Tested by

no test coverage detected