(self, changed_files: List[str], args: FormatArgs)
| 206 | return proc.returncode == 0 |
| 207 | |
| 208 | def format_run(self, changed_files: List[str], args: FormatArgs) -> Optional[str]: |
| 209 | cpp_files = self.filter_changed_files(changed_files) |
| 210 | if not cpp_files: |
| 211 | return None |
| 212 | |
| 213 | cf_cmd = [ |
| 214 | self.clang_fmt_path, |
| 215 | "--binary=clang-format-19", |
| 216 | "--diff", |
| 217 | ] |
| 218 | |
| 219 | if args.start_rev and args.end_rev: |
| 220 | cf_cmd.append(args.start_rev) |
| 221 | cf_cmd.append(args.end_rev) |
| 222 | |
| 223 | cf_cmd.append("--") |
| 224 | cf_cmd += cpp_files |
| 225 | |
| 226 | if args.verbose: |
| 227 | print(f"Running: {' '.join(cf_cmd)}") |
| 228 | self.cf_cmd = cf_cmd |
| 229 | proc = subprocess.run(cf_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 230 | sys.stdout.write(proc.stderr.decode("utf-8")) |
| 231 | |
| 232 | if proc.returncode != 0: |
| 233 | # formatting needed, or the command otherwise failed |
| 234 | if args.verbose: |
| 235 | print(f"error: {self.name} exited with code {proc.returncode}") |
| 236 | # Print the diff in the log so that it is viewable there |
| 237 | print(proc.stdout.decode("utf-8")) |
| 238 | return proc.stdout.decode("utf-8") |
| 239 | else: |
| 240 | return None |
| 241 | |
| 242 | ALL_FORMATTERS = [ClangFormatHelper()] |
| 243 |
nothing calls this directly
no test coverage detected