MCPcopy Create free account
hub / github.com/apache/kvrocks / clang_format

Function clang_format

x.py:182–202  ·  view source on GitHub ↗
(clang_format_path: str, fix: bool = False)

Source from the content-addressed store, hash-verified

180
181
182def clang_format(clang_format_path: str, fix: bool = False) -> None:
183 command = find_command(clang_format_path, msg="clang-format is required")
184
185 version_res = run_pipe(command, '--version').read().strip()
186 version_re_res = re.search(r'version\s+((?:\w|\.)+)', version_res)
187 if version_re_res:
188 version_str = version_re_res.group(1)
189 else:
190 raise RuntimeError(f"version not found in `{command} --version`")
191
192 check_version(version_str, CLANG_FORMAT_REQUIRED_VERSION, "clang-format")
193
194 basedir = Path(__file__).parent.absolute()
195 sources = get_source_files(basedir)
196
197 if fix:
198 options = ['-i']
199 else:
200 options = ['--dry-run', '--Werror']
201
202 run(command, *options, *sources, verbose=True, cwd=basedir)
203
204
205def clang_tidy(dir: str, jobs: Optional[int], clang_tidy_path: str, run_clang_tidy_path: str, fix: bool) -> None:

Callers 1

x.pyFile · 0.85

Calls 6

find_commandFunction · 0.85
run_pipeFunction · 0.85
check_versionFunction · 0.85
get_source_filesFunction · 0.85
runFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected