]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Filter file diffs that are not in the current project
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 20 Apr 2023 20:31:54 +0000 (22:31 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Fri, 21 Apr 2023 11:51:11 +0000 (13:51 +0200)
.github/scripts/git-filter.py [new file with mode: 0755]
.github/workflows/build-and-test-all.yml

diff --git a/.github/scripts/git-filter.py b/.github/scripts/git-filter.py
new file mode 100755 (executable)
index 0000000..5331116
--- /dev/null
@@ -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())
index e739236c86229aa7bed95a2979c938f0413d535c..bad2c65e62e8ad653eeb58497852ccc33344f61d 100644 (file)
@@ -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: |