From: Fred Morcos Date: Thu, 20 Apr 2023 20:31:54 +0000 (+0200) Subject: Filter file diffs that are not in the current project X-Git-Tag: auth-4.8.0~15^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3121aac576721cba60f05315d994f5ee146b642f;p=thirdparty%2Fpdns.git Filter file diffs that are not in the current project --- diff --git a/.github/scripts/git-filter.py b/.github/scripts/git-filter.py new file mode 100755 index 0000000000..533111606d --- /dev/null +++ b/.github/scripts/git-filter.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +"""Filter git diff files that are not in the product. + +Filter files out of a git diff output that are not part of the product found in +the current directory. + +""" + +import os +import sys + +import helpers +import unidiff + + +def main(): + """Start the script.""" + compdb = helpers.load_compdb("compile_commands.json") + compdb = helpers.index_compdb(compdb) + + root = helpers.get_repo_root() + + diff = sys.stdin.read() + patch_set = unidiff.PatchSet(diff) + for patch in patch_set: + path = os.path.join(root, patch.path) + if path in compdb: + print(patch) + + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/workflows/build-and-test-all.yml b/.github/workflows/build-and-test-all.yml index e739236c86..bad2c65e62 100644 --- a/.github/workflows/build-and-test-all.yml +++ b/.github/workflows/build-and-test-all.yml @@ -48,7 +48,7 @@ jobs: - run: ln -s .clang-tidy.full .clang-tidy - name: Run clang-tidy working-directory: pdns - run: git diff -U0 HEAD^..HEAD | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p2 -export-fixes clang-tidy-auth.yml + run: git diff -U0 HEAD^..HEAD | python3 ../.github/scripts/git-filter.py | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p2 -export-fixes clang-tidy-auth.yml - name: Print clang-tidy fixes YAML working-directory: pdns shell: bash @@ -116,7 +116,7 @@ jobs: - run: inv ci-rec-make-bear - run: ln -s ../../.clang-tidy.full .clang-tidy - name: Run clang-tidy - run: git diff -U0 HEAD^..HEAD | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p3 -export-fixes clang-tidy-rec.yml + run: git diff -U0 HEAD^..HEAD | python3 ../../.github/scripts/git-filter.py | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p3 -export-fixes clang-tidy-rec.yml - name: Print clang-tidy fixes YAML shell: bash run: | @@ -185,7 +185,7 @@ jobs: - run: inv ci-dnsdist-make-bear - run: ln -s ../../.clang-tidy.full .clang-tidy - name: Run clang-tidy - run: git diff -U0 HEAD^..HEAD | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p3 -export-fixes clang-tidy-dnsdist.yml + run: git diff -U0 HEAD^..HEAD | python3 ../../.github/scripts/git-filter.py | python3 /usr/bin/clang-tidy-diff-12.py -clang-tidy-binary /usr/bin/clang-tidy-12 -extra-arg=-ferror-limit=0 -p3 -export-fixes clang-tidy-dnsdist.yml - name: Print clang-tidy fixes YAML shell: bash run: |