|
29 | 29 | import shutil |
30 | 30 |
|
31 | 31 | from pathlib import Path |
32 | | -from utils import Version, ci_group, is_ci, is_alpinelike, is_debianlike, is_macos, is_windows, is_msys |
| 32 | +from utils import Version, ci_group, is_ci, is_alpinelike, is_debianlike, is_macos, is_windows, is_msys, FormattingError, format_meson |
33 | 33 |
|
34 | 34 | PERMITTED_FILES = {'generator.sh', 'meson.build', 'meson_options.txt', 'meson.options', 'LICENSE.build'} |
35 | 35 | PER_PROJECT_PERMITTED_FILES: dict[str, set[str]] = { |
@@ -606,19 +606,6 @@ def is_permitted_file(self, subproject: str, filename: str) -> bool: |
606 | 606 | return True |
607 | 607 | return False |
608 | 608 |
|
609 | | - def is_formatted_correctly(self, file: Path) -> bool: |
610 | | - res = subprocess.run( |
611 | | - [ |
612 | | - "meson", |
613 | | - "format", |
614 | | - "--check-only", |
615 | | - "--configuration", |
616 | | - "./meson.format", |
617 | | - file.absolute(), |
618 | | - ] |
619 | | - ) |
620 | | - return res.returncode == 0 |
621 | | - |
622 | 609 | def check_project_args(self, name: str, dir: Path) -> None: |
623 | 610 | if not dir.exists(): |
624 | 611 | # build has not run and unpacked the source; do that |
@@ -684,8 +671,11 @@ def check_files(self, subproject: str, patch_path: Path) -> None: |
684 | 671 | for f in patch_path.rglob('*'): |
685 | 672 | if f.is_dir(): |
686 | 673 | continue |
687 | | - if f.name in FORMAT_CHECK_FILES and not self.is_formatted_correctly(f): |
688 | | - unformatted.append(f) |
| 674 | + if f.name in FORMAT_CHECK_FILES: |
| 675 | + try: |
| 676 | + format_meson([f], check=True) |
| 677 | + except FormattingError: |
| 678 | + unformatted.append(f) |
689 | 679 | if not self.is_permitted_file(subproject, f.name): |
690 | 680 | not_permitted.append(f) |
691 | 681 | elif f.name in NO_TABS_FILES and '\t' in f.read_text(encoding='utf-8'): |
|
0 commit comments