Skip to content

Block sync when git working tree is dirty#371

Merged
tschm merged 5 commits intomainfrom
copilot/make-sync-impossible-if-status-not-clean
Mar 7, 2026
Merged

Block sync when git working tree is dirty#371
tschm merged 5 commits intomainfrom
copilot/make-sync-impossible-if-status-not-clean

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

rhiza sync could run against a repository with uncommitted changes, making it impossible to distinguish between local edits and sync-applied changes, and risking unrecoverable work.

Changes

  • _sync_helpers.py — adds _assert_git_status_clean(): runs git status --porcelain on the target; raises RuntimeError with the list of dirty files if output is non-empty
  • sync.py — calls _assert_git_status_clean() as the first operation in sync(), before branch handling or any template work
  • test_sync.py — adds TestAssertGitStatusClean covering: clean tree (no raise), untracked file, and staged-but-uncommitted file

Behaviour

$ rhiza sync
[ERROR] Working tree is not clean. Please commit or stash your changes before syncing.
[ERROR] Uncommitted changes:
[ERROR]   ?? some-untracked-file.txt
[ERROR]  M modified-file.py
Original prompt

This section details on the original issue you should resolve

<issue_title>Make it impossible to do perform sync if git status is not clean</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@tschm tschm marked this pull request as ready for review March 7, 2026 12:13
Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Copilot AI changed the title [WIP] Add restriction to prevent sync with unclean git status Block sync when git working tree is dirty Mar 7, 2026
Copilot finished work on behalf of tschm March 7, 2026 12:20
@tschm tschm merged commit a7f59e0 into main Mar 7, 2026
16 checks passed
@tschm tschm deleted the copilot/make-sync-impossible-if-status-not-clean branch March 7, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it impossible to do perform sync if git status is not clean

2 participants