diff options
author | Nick Brassel <[email protected]> | 2024-07-24 15:16:51 +1000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-24 06:16:51 +0100 |
commit | 8c35011d0aa242e9f6271d3a66ae6924d52bbed6 (patch) | |
tree | 7c20eb2459a49446c4e3b47292134e985eede9fe /lib | |
parent | 8c5acdea12543dbc86e9b85fe41cbb98d90bbd18 (diff) | |
download | qmk_firmware-8c35011d0aa242e9f6271d3a66ae6924d52bbed6.tar.gz qmk_firmware-8c35011d0aa242e9f6271d3a66ae6924d52bbed6.zip |
[CLI] Only generate files if contents change. (#24038)
Don't overwrite if the content doesn't change.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/qmk/commands.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 3db8353bfd..df6ed6b88a 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -101,6 +101,12 @@ def dump_lines(output_file, lines, quiet=True): if output_file and output_file.name != '-': output_file.parent.mkdir(parents=True, exist_ok=True) if output_file.exists(): + with open(output_file, 'r', encoding='utf-8', newline='\n') as f: + existing = f.read() + if existing == generated: + if not quiet: + cli.log.info(f'No changes to {output_file.name}.') + return output_file.replace(output_file.parent / (output_file.name + '.bak')) output_file.write_text(generated, encoding='utf-8') |