cli: make some functions only create commits optionally

This commit is contained in:
Michael Hoang
2025-02-13 15:09:17 +07:00
parent 742040cd03
commit 0d9963c1a6
2 changed files with 12 additions and 8 deletions

View File

@@ -522,7 +522,9 @@ def get_inventory_with_writeable_keys(
@API.register
def set_inventory(inventory: Inventory, flake_dir: str | Path, message: str) -> None:
def set_inventory(
inventory: Inventory, flake_dir: str | Path, message: str, commit: bool = True
) -> None:
"""
Write the inventory to the flake directory
and commit it to git with the given message
@@ -553,7 +555,8 @@ def set_inventory(inventory: Inventory, flake_dir: str | Path, message: str) ->
with inventory_file.open("w") as f:
json.dump(persisted, f, indent=2)
commit_file(inventory_file, Path(flake_dir), commit_message=message)
if commit:
commit_file(inventory_file, Path(flake_dir), commit_message=message)
@API.register