From 33e6271b65cc147ddc114ffe5bfd4fd1ae821188 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 26 Sep 2024 23:31:14 +0200 Subject: [PATCH] Make --compare print diffs --- ros2nix/ros2nix.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ros2nix/ros2nix.py b/ros2nix/ros2nix.py index 3e641c0..616b440 100755 --- a/ros2nix/ros2nix.py +++ b/ros2nix/ros2nix.py @@ -4,6 +4,7 @@ # Copyright 2024 Michal Sojka import argparse +import difflib import io import itertools import json @@ -77,6 +78,13 @@ def file_writer(path: str, compare: bool): current = f.getvalue() if current != ondisk: err(f"{path} is not up-to-date") + for line in difflib.unified_diff( + ondisk.splitlines(), + current.splitlines(), + fromfile=path, + tofile="up-to-date", + ): + print(line) global compare_failed compare_failed = True f.close()