Make --compare print diffs

This commit is contained in:
Michal Sojka 2024-09-26 23:31:14 +02:00
parent 61f9d71bc8
commit 33e6271b65

View file

@ -4,6 +4,7 @@
# Copyright 2024 Michal Sojka <michal.sojka@cvut.cz> # Copyright 2024 Michal Sojka <michal.sojka@cvut.cz>
import argparse import argparse
import difflib
import io import io
import itertools import itertools
import json import json
@ -77,6 +78,13 @@ def file_writer(path: str, compare: bool):
current = f.getvalue() current = f.getvalue()
if current != ondisk: if current != ondisk:
err(f"{path} is not up-to-date") 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 global compare_failed
compare_failed = True compare_failed = True
f.close() f.close()