Lines Matching +full:clang +full:- +full:format +full:- +full:diff

7 #      http://www.apache.org/licenses/LICENSE-2.0
30 # pylint: disable=wrong-import-position
48 def __init__(self, diff=()): argument
52 diff: The list of files that changed.
54 self.diff = diff
74 prev_arg = ret[-1]
75 ret = ret[0:-1]
80 prefix = arg[0:-len('${PREUPLOAD_FILES_PREFIXED}')]
129 return [x.file for x in self.diff if x.status != 'D']
143 """The root of the repo (sub-manifest) checkout."""
168 scope: A list of shell-style wildcards (fnmatch) or regular
209 def expand_vars(args, diff=()): argument
211 replacer = Placeholders(diff=diff)
214 def args(self, default_args=(), diff=()): argument
219 diff: The list of files that changed in the current commit.
228 return self.expand_vars(args, diff=diff)
285 def _filter_diff(diff, include_list, exclude_list=()): argument
289 diff: list of diff objects to filter.
302 for d in diff:
315 A string in a format usable to get prebuilt tool paths.
319 return 'darwin-x86'
322 return 'linux-x86'
340 def check_custom(project, commit, _desc, diff, options=None, **kwargs): argument
342 return _check_cmd(options.name, project, commit, options.args((), diff),
346 def check_aosp_license(project, commit, _desc, diff, options=None): argument
350 if x.startswith('--exclude-dirs=')]
351 exclude_dirs = [x[len('--exclude-dirs='):].split(',')
355 # Filter diff based on extension.
373 diff = _filter_diff(diff, include_list, exclude_list)
375 # Only check the new-added files.
376 diff = [d for d in diff if d.status == 'A']
378 if not diff:
381 cmd = [get_helper_path('check_aosp_license.py'), '--commit_hash', commit]
382 cmd += HookOptions.expand_vars(('${PREUPLOAD_FILES}',), diff)
386 def check_bpfmt(project, commit, _desc, diff, options=None): argument
388 filtered = _filter_diff(diff, [r'\.bp$'])
394 cmd = [bpfmt, '-d'] + bpfmt_options
395 fixup_cmd = [bpfmt, '-w']
396 if '-s' in bpfmt_options:
397 fixup_cmd.append('-s')
398 fixup_cmd.append('--')
413 def check_checkpatch(project, commit, _desc, diff, options=None): argument
414 """Run |diff| through the kernel's checkpatch.pl tool."""
416 cmd = ([tool, '-', '--root', project.dir] +
417 options.args(('--ignore=GERRIT_CHANGE_ID',), diff))
422 def check_clang_format(project, commit, _desc, diff, options=None): argument
423 """Run git clang-format on the commit."""
424 tool = get_helper_path('clang-format.py')
425 clang_format = options.tool_path('clang-format')
426 git_clang_format = options.tool_path('git-clang-format')
427 tool_args = (['--clang-format', clang_format, '--git-clang-format',
429 options.args(('--style', 'file', '--commit', commit), diff))
431 fixup_cmd = [tool, '--fix'] + tool_args
432 return _check_cmd('clang-format', project, commit, cmd,
437 """Run google-java-format on the commit."""
439 if x.startswith('--include-dirs=')]
440 include_dirs = [x[len('--include-dirs='):].split(',')
454 tool = get_helper_path('google-java-format.py')
455 google_java_format = options.tool_path('google-java-format')
456 google_java_format_diff = options.tool_path('google-java-format-diff')
457 tool_args = ['--google-java-format', google_java_format,
458 '--google-java-format-diff', google_java_format_diff,
459 '--commit', commit] + args
462 fixup_cmd = [tool, '--fix'] + tool_args
463 return [rh.results.HookCommandResult('google-java-format', project, commit,
469 def check_ktfmt(project, commit, _desc, diff, options=None): argument
473 if x.startswith('--include-dirs=')]
474 include_dirs = [x[len('--include-dirs='):].split(',')
481 filtered = _filter_diff(diff, patterns)
489 cmd = [ktfmt, '--dry-run'] + args + HookOptions.expand_vars(
502 regex = r'^(Bug|Fix): (None|[0-9]+(, [0-9]+)*)$'
516 f'following case-sensitive regex:\n\n {regex}'
526 """Check the commit message for a 'Change-Id:' line."""
527 field = 'Change-Id'
528 regex = fr'^{field}: I[a-f0-9]+$'
542 f'following case-sensitive regex:\n\n {regex}'
559 for apk in $(find . -name '*.apk' | sort); do
562 grep -iE "(package: |sdkVersion:|targetSdkVersion:)" |
563 sed -e "s/' /'\\n/g"
567 It must match the following case-sensitive multiline regex searches:
571 For more information, see go/platform-prebuilt and go/android-prebuilt.
576 def check_commit_msg_prebuilt_apk_fields(project, commit, desc, diff, argument
583 filtered = _filter_diff(diff, [r'\.apk$'])
612 following case-sensitive regex:
616 The Test: stanza is free-form and should describe how you tested your change.
625 Test: make test-art
626 Test: manual - took a photo
629 Check the git history for more examples. It's a free-form field, so we urge
636 high-quality Test: descriptions.
668 The Relnote: stanza is free-form and should describe what developers need to
677 Check the git history for more examples. It's a free-form field, so we urge
685 Multi-line Relnote example:
690 Single-line Relnote example:
700 Non-starting/non-ending quote Relnote examples:
715 (3) Checks that release notes that contain non-starting or non-ending
730 'Rel-note', 'Rel note',
731 'rel-notes', 'releasenotes',
732 'release-note', 'release-notes',
752 regex_other_fields = r'^[a-zA-Z0-9-]+:'
760 i < len(desc_lines) - 1 and
790 # A single-line Relnote containing a start and ending triple quote
795 # A single-line Relnote containing a start and ending quote
797 if cur_line.count('"') - cur_line.count('\\"') == 2:
806 # Check 4: Check that non-starting or non-ending quotes are escaped with a
837 and 0 < i < len(stripped_line) - 1
838 and stripped_line[i-1] != '"'
839 and stripped_line[i-1] != "\\"):
857 The Relnote: stanza is free-form and should describe what developers need to
872 def check_commit_msg_relnote_for_current_txt(project, commit, desc, diff, argument
883 diff,
905 def check_cpplint(project, commit, _desc, diff, options=None): argument
909 filtered = _filter_diff(diff, [r'\.(cc|h|cpp|cu|cuh)$'])
918 def check_gofmt(project, commit, _desc, diff, options=None): argument
920 filtered = _filter_diff(diff, [r'\.go$'])
925 cmd = [gofmt, '-l'] + options.args()
926 fixup_cmd = [gofmt, '-w'] + options.args()
939 def check_json(project, commit, _desc, diff, options=None): argument
944 filtered = _filter_diff(diff, [r'\.json$'])
960 def _check_pylint(project, commit, _desc, diff, extra_args=None, options=None): argument
962 filtered = _filter_diff(diff, [r'\.py$'])
972 '--executable-path', pylint,
977 def check_pylint2(project, commit, desc, diff, options=None): argument
979 return _check_pylint(project, commit, desc, diff, options=options)
982 def check_pylint3(project, commit, desc, diff, options=None): argument
984 return _check_pylint(project, commit, desc, diff,
985 extra_args=['--py3'],
989 def check_rustfmt(project, commit, _desc, diff, options=None): argument
990 """Run "rustfmt --check" on diffed rust files"""
991 filtered = _filter_diff(diff, [r'\.rs$'])
1008 # TODO(b/164111102): rustfmt stable does not support --check on stdin.
1017 def check_xmllint(project, commit, _desc, diff, options=None): argument
1021 'dbus-xml', # Generated DBUS interface.
1022 'dia', # File format for Dia.
1050 filtered = _filter_diff(diff, [r'\.(' + '|'.join(extensions) + r')$'])
1061 def check_android_test_mapping(project, commit, _desc, diff, options=None): argument
1065 filtered = _filter_diff(diff, [r'(^|.*/)TEST_MAPPING$'])
1069 testmapping_format = options.tool_path('android-test-mapping-format')
1070 testmapping_args = ['--commit', commit]
1073 return _check_cmd('android-test-mapping-format', project, commit, cmd)
1076 def check_aidl_format(project, commit, _desc, diff, options=None): argument
1077 """Checks that AIDL files are formatted with aidl-format."""
1079 filtered = _filter_diff(diff, [r'\.aidl$'], [r'(^|/)aidl_api/'])
1082 aidl_format = options.tool_path('aidl-format')
1083 clang_format = options.tool_path('clang-format')
1084 diff_cmd = [aidl_format, '-d', '--clang-format-path', clang_format] + \
1091 fixup_cmd = [aidl_format, '-w', '--clang-format-path', clang_format]
1093 'aidl-format', project, commit, error=result.stdout,
1129 'aidl-format': 'aidl-format',
1130 'android-test-mapping-format':
1133 'clang-format': 'clang-format',
1135 'git-clang-format': 'git-clang-format',
1137 'google-java-format': 'google-java-format',
1138 'google-java-format-diff': 'google-java-format-diff.py',