Write a config file with a git checkpoint
git_safe_write_with_checkpointWrite a Home Assistant config file after committing a git checkpoint of its prior state, then commit the new content to keep a rollback point.
Instructions
Write one config file after committing a checkpoint of the prior state.
Stages and commits every uncommitted change under /config as a
checkpoint commit (only when the tree is dirty), then calls the same
write_config_file logic files_write_config_file uses for
relative_path/content, and finally stages and commits that change
with commit_message (or a default message) if the write succeeded.
Use when: overwriting a config file while keeping a git-based rollback
point, unlike a plain overwrite.
Not for: a write without a checkpoint — use
files_write_config_file; ESPHome device YAML — use
esphome_write_config.
Returns: dict — the underlying write result ({"success": True, "path": ...} or {"success": False, "error": ...}), plus git_sha/
git_message when the new-content commit was made.
Errors: raises RuntimeError (from _repo()) when no git repo exists
— run git_git_init_config first; returns {"success": False, "error": ...} unchanged when YAML validation fails, in which case the
checkpoint commit of the prior dirty state (if any) still happened, but
no new-content commit is made.
Limits: does not reload Home Assistant; same file-extension and
location limits as files_write_config_file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Full text to write as the file's new content, replacing whatever was there before. | |
| relative_path | Yes | Path to the file relative to the HA config directory to write, e.g. 'automations.yaml'. Same extension and location limits as `files_write_config_file`. | |
| commit_message | No | Commit message for the new-content commit. Omit to use a default 'chore: update <relative_path>' message. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||