]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy.py: We need to output relative paths in annotations 13330/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 3 Oct 2023 13:47:04 +0000 (15:47 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 5 Oct 2023 08:35:28 +0000 (10:35 +0200)
.github/scripts/clang-tidy.py

index 856be887f67c187582be0fc1302523afb9ca71b3..4fafc03e168ce1e6d2ef7bd5794bc71ef59526ae 100755 (executable)
@@ -33,6 +33,7 @@ def main():
     """Start the script."""
     args = create_argument_parser()
 
+    repo_root_dir = Path(helpers.get_repo_root())
     fixes_path = Path(args.fixes_file)
     compdb_filename = os.path.join(fixes_path.parent, "compile_commands.json")
     compdb = helpers.load_compdb(compdb_filename)
@@ -67,14 +68,6 @@ def main():
             else os.path.join(directory, filename)
         )
 
-        if full_filename not in compdb:
-            print(
-                f"Skipping `{full_filename}`"
-                " because it is not found"
-                " in the compilation database"
-            )
-            continue
-
         try:
             file_contents = helpers.load_file(full_filename)
         except OSError:
@@ -85,16 +78,17 @@ def main():
 
         line = helpers.get_line_from_offset(file_contents, offset)
 
+        relative_filename = Path(full_filename).resolve().relative_to(repo_root_dir)
         annotation = "".join(
             [
-                f"::warning file={full_filename},line={line}",
+                f"::warning file={relative_filename},line={line}",
                 f"::{message} ({name} - Level={level})",
             ]
         )
         print(annotation)
 
         # User-friendly printout
-        print(f"{level}: {full_filename}:{line}: {message} ({name})")
+        print(f"{level}: {relative_filename}:{line}: {message} ({name})")
 
         have_warnings = True