276978ff1f
Now clang-format report will skip files matching `clang-format.ignore`. For now it's empty. clang-tidy will not receive diffs for `clang-tidy.ignore` (it still can produce warnings for these files). In addition build bot will not will not post comments for files that are matched by `clang-tidy-comments.ignore`. Now project/file should be whitelisted to receive inline comments from clang-tidy. Added all /test directories to `clang-tidy.ignore`. Other alternatives considered: - using 'compile_commands.json': does not contain header files. - specifying -regex option to 'clang-tidy-diff': probably not the best experience of providing multiple rules and maintaining a single regex.
39 lines
1.3 KiB
Python
Executable file
39 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# Copyright 2020 Google LLC
|
|
#
|
|
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# https://llvm.org/LICENSE.txt
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import re
|
|
import sys
|
|
import pathspec
|
|
|
|
# Takes an output of git diff and removes files ignored by patten specified by ignore file.
|
|
def main():
|
|
argv = sys.argv[1:]
|
|
if not argv:
|
|
print("Please provide a path to .ignore file.")
|
|
sys.exit(1)
|
|
ignore = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern,
|
|
open(argv[0], 'r').readlines())
|
|
good = True
|
|
for line in sys.stdin:
|
|
match = re.search(r'^diff --git a/(.*) b/(.*)$', line)
|
|
if match:
|
|
good = not (ignore.match_file(match.group(1)) and ignore.match_file(match.group(2)))
|
|
if not good:
|
|
continue
|
|
sys.stdout.write(line)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|