]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fixup Github clang-tidy helper scripts 13683/head
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 2 Jan 2024 14:13:30 +0000 (15:13 +0100)
committerFred Morcos <fred.morcos@open-xchange.com>
Tue, 9 Jan 2024 08:58:42 +0000 (09:58 +0100)
.github/scripts/clang-tidy.py
.github/scripts/git-filter.py

index d7867c830154995bcb472966d484691ac3bea6b2..a68c7eec13c045fdf87fe9207194e2b21374a142 100755 (executable)
@@ -45,11 +45,11 @@ def main():
         print("No diagnostics or warnings produced by clang-tidy")
         return 0
 
-    gh_step_summary = os.getenv('GITHUB_STEP_SUMMARY')
+    gh_step_summary = os.getenv("GITHUB_STEP_SUMMARY")
     if gh_step_summary:
         # Print Markdown summary
-        summaryFp = open(gh_step_summary, 'a', encoding='utf-8')
-        print('### clang-tidy summary', file=summaryFp)
+        summary_fp = open(gh_step_summary, "a", encoding="utf-8")
+        print("### clang-tidy summary", file=summary_fp)
 
     fixes = fixes["Diagnostics"]
     have_warnings = False
@@ -84,20 +84,23 @@ def main():
 
         line = helpers.get_line_from_offset(file_contents, offset)
 
-        relative_filename = Path(full_filename).resolve().relative_to(repo_root_dir)
+        rel_filename = Path(full_filename).resolve().relative_to(repo_root_dir)
         annotation = "".join(
             [
-                f"::warning file={relative_filename},line={line}",
+                f"::warning file={rel_filename},line={line}",
                 f"::{message} ({name} - Level={level})",
             ]
         )
         print(annotation)
 
         # User-friendly printout
-        print(f"{level}: {relative_filename}:{line}: {message} ({name})")
+        print(f"{level}: {rel_filename}:{line}: {message} ({name})")
 
         if gh_step_summary:
-            print(f'- **{relative_filename}:{line}** {message} (`{name}`)', file=summaryFp)
+            print(
+                f"- **{rel_filename}:{line}** {message} (`{name}`)",
+                file=summary_fp,
+            )
 
         have_warnings = True
 
index 32b4fd469128548629400a23dab7ffc3c9266369..46f605795ea4fd54f23b7066a9358e63dce763f2 100755 (executable)
@@ -15,6 +15,7 @@ from pathlib import Path
 import helpers
 import unidiff
 
+
 def create_argument_parser():
     """Create command-line argument parser."""
     parser = argparse.ArgumentParser(
@@ -42,27 +43,38 @@ def main():
     diff = sys.stdin.read()
     patch_set = unidiff.PatchSet(diff)
     for patch in patch_set:
-        # We have to deal with several possible cases for input files, as shown by git:
+        # We have to deal with several possible cases for input files, as shown
+        # by git:
+        #
         # - in ext/: ext/lmdb-safe/lmdb-safe.cc
         # - in modules/: modules/lmdbbackend/lmdbbackend.cc
-        # - files that live in the dnsdist or rec dir only: pdns/dnsdistdist/dnsdist-dnsparser.cc or pdns/recursordist/rec-tcp.cc
-        # - files that live in pdns/ and are used by several products (but possibly not with the same compilation flags, so
-        #   it is actually important that they are processed for all products: pdns/misc.cc
+        # - files that live in the dnsdist or rec dir only:
+        #   pdns/dnsdistdist/dnsdist-dnsparser.cc or
+        #   pdns/recursordist/rec-tcp.cc
+        # - files that live in pdns/ and are used by several products (but
+        #   possibly not with the same compilation flags, so it is actually
+        #   important that they are processed for all products: pdns/misc.cc
         path = Path(patch.path)
-        if product == 'auth':
+        if product == "auth":
             path = Path(cwd).joinpath(path)
         else:
-            if str(path).startswith('modules'):
-                print(f'Skipping {path}: modules do not apply to {product}', file=sys.stderr)
+            if str(path).startswith("modules"):
+                print(
+                    f"Skipping {path}: modules do not apply to {product}",
+                    file=sys.stderr,
+                )
                 continue
 
-            if str(path).startswith('ext'):
+            if str(path).startswith("ext"):
                 subpath = Path(cwd).joinpath(path)
             else:
                 subpath = Path(cwd).joinpath(path.name)
 
             if not subpath.exists():
-                print(f'Skipping {path}: does not exist for {product} ({subpath})', file=sys.stderr)
+                print(
+                    f"Skip {path}: doesn't exist for {product} ({subpath})",
+                    file=sys.stderr,
+                )
                 continue
 
             path = subpath
@@ -71,7 +83,10 @@ def main():
             patch.target_file = str(path)
 
         if not str(path) in compdb:
-            print(f'Skipping {path}: it is not in the compilation db', file=sys.stderr)
+            print(
+                f"Skipping {path}: it is not in the compilation db",
+                file=sys.stderr,
+            )
             continue
 
         print(patch, file=sys.stderr)